Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public function changePassword(Request $request)
  2. {
  3. $user = Auth::user();
  4.  
  5. $curPassword = $request->input['curPassword'];
  6. $newPassword = $request->input['newPassword'];
  7.  
  8. if (Hash::check($curPassword, $user->password)) {
  9. $user_id = $user->id;
  10. $obj_user = User::find($user_id)->first();
  11. $obj_user->password = Hash::make($newPassword);
  12. $obj_user->save();
  13.  
  14. return response()->json(["result"=>true]);
  15. }
  16. else
  17. {
  18. return response()->json(["result"=>false]);
  19. }
  20. }
  21.  
  22. $curPassword = $request->curPassword;
  23. $newPassword = $request->newPassword;
  24.  
  25. $curPassword =$request->input('curPassword');
  26. $newPassword = $request->input('newPassword');
  27.  
  28. $curPassword = $request->input['curPassword'];
  29. $newPassword = $request->input['newPassword'];
  30.  
  31. $request->user()->fill([
  32. 'password' => Hash::make($request->newPassword)
  33. ])->save();
  34.  
  35. public function changePassword()
  36. {
  37. $this->validate(request(), [
  38. 'current_password' => 'required|current_password',
  39. 'new_password' => 'required|string|min:6|confirmed',
  40. ]);
  41.  
  42. request()->user()->fill([
  43. 'password' => Hash::make(request()->input('new_password'))
  44. ])->save();
  45. request()->session()->flash('success', 'Password changed!');
  46.  
  47. return redirect()->route('password.change');
  48. }
  49.  
  50. public function boot()
  51. {
  52. // current password validation rule
  53. Validator::extend('current_password', function ($attribute, $value, $parameters, $validator) {
  54. return Hash::check($value, Auth::user()->password);
  55. });
  56. }
  57.  
  58. 'current_password' => "The :attribute is invalid.",
  59.  
  60. $obj_user = User::find($user_id)->first();
  61.  
  62. $obj_user = User::find($user_id);
  63.  
  64. // Retrieve a model by its primary key...
  65. $flight = AppFlight::find(1);
  66.  
  67. // Retrieve the first model matching the query constraints...
  68. $flight = AppFlight::where('active', 1)->first();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement