User Profile

The user is able to change update his profile information.


The profile can be accessed by a logged in user by clicking User Profile from the sidebar or adding user-profile in the url. The user can add information like phone number, location, description or change the name, email, profile picture and password.

The App/Http/Controllers/UserController.php handles the update of the user information and password.

              
                public function passwordUpdate(){

                  request()->validate([
                      'old_password' => 'required',
                      'password' => 'required|min:7|confirmed',
                  ]);

                  $hashedPassword = auth()->user()->password;

                  if (Hash::check(request()->old_password , $hashedPassword)) {
                      if (!Hash::check(request()->password , $hashedPassword))
                      {
                          $users = User::findorFail(auth()->user()->id);
                          $users->password = request()->password;
                          $users->save();
                          return back()->with(['success'=>'Password successfully updated.']);
                      }
                      else{
                          return back()->with(['error' =>"New password can not be the old password!"]);
                      }
                  }
                  else{
                      return back()->with(['error' =>"Old password doesn't match"]);
                  }
              }