id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('_id', $user->StaffDetail->company_id)->first(); return view('v3.main-contractor.profile', compact('user','site','company')); } public function updatePassword(Request $request){ $validator = Validator::make($request->all(), [ 'password' => 'min:8|confirmed', ]); if ($validator->fails()) { return redirect()->back()->withInput()->withErrors($validator); } $staff = Staff::with('StaffDetail')->where('_id', $request->_id)->first(); if(!empty($staff)) { $encryptP = Hash::make($request->get('password')); $staff->password = $encryptP; $staff->save(); $staff->StaffDetail->password = $encryptP; $staff->StaffDetail->save(); return redirect()->back()->with('success_msg', 'Success! update password'); }else { return redirect()->back()->withInput()->with('error_msg','Staff id not found'); } } }