Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ProfileController.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Http\Controllers\v3\Contractor;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Auth;
  6. use Validator;
  7. use Hash;
  8. use App\SiteSetting;
  9. use App\LatestModel\Staff;
  10. use App\LatestModel\StaffDetail;
  11. use App\LatestModel\Module\Form;
  12. use App\LatestModel\Module\Subscriber;
  13. use App\LatestModel\Module\WorkOrder;
  14. use App\LatestModel\Module\PackageDetail;
  15. use App\LatestModel\Module\Company;
  16. class ProfileController extends Controller
  17. {
  18. /**
  19. * Create a profile controller.
  20. *
  21. * @return value
  22. */
  23. public function staffProfile(){
  24. $id = Auth::guard('main-contractor')->id();
  25. $user = Staff::with('StaffDetail')->find($id);
  26. $site = SiteSetting::first();
  27. $company = Company::where('_id', $user->StaffDetail->company_id)->first();
  28. return view('v3.main-contractor.profile', compact('user','site','company'));
  29. }
  30. public function updatePassword(Request $request){
  31. $validator = Validator::make($request->all(), [
  32. 'password' => 'min:8|confirmed',
  33. ]);
  34. if ($validator->fails()) {
  35. return redirect()->back()->withInput()->withErrors($validator);
  36. }
  37. $staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first();
  38. if(!empty($staff)) {
  39. $encryptP = Hash::make($request->get('password'));
  40. $staff->password = $encryptP;
  41. $staff->save();
  42. $staff->StaffDetail->password = $encryptP;
  43. $staff->StaffDetail->save();
  44. return redirect()->back()->with('success_msg', 'Success! update password');
  45. }else {
  46. return redirect()->back()->withInput()->with('error_msg','Staff id not found');
  47. }
  48. }
  49. }