public function change_password(PasswordChangeRequest $request) { $password = $request->all(); if ($password['password'] === $password['password_confirmation']) { User::find(Auth::user()->id)->update(['password' => bcrypt($password['password'])]); return redirect('/admin')->with(['password_update' => 'Your password has been updated', 'class' => 'success']); } else { return redirect('/admin')->with(['password_update' => 'Your passwords don\'t match', 'class' => 'danger']); } }
public function update_password($username, PasswordChangeRequest $request) { if (Auth::validate(['phone' => Auth::user()->phone, 'password' => $request->input('old_password')])) { Auth::user()->password = bcrypt($request->input('password')); Auth::user()->save(); return redirect()->back()->with('success', 'Password updated successfully'); } else { return redirect()->back()->with('error', 'Current password do not match with one in our record!'); } }