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. The user can add information like phone number, location or change the name, email, profile picture and password.

The App/Http/Livewire/LaravelExamples/Profile/Edit.php handles the update of the user information and password.

              
                public function passwordUpdate(){

                  $this->validate([
                      'old_password' => 'required',
                      'new_password' => 'required|min:7|same:confirmationPassword',
                  ]);

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

                  if (Hash::check($this->old_password , $hashedPassword)) {
                      if (!Hash::check($this->new_password , $hashedPassword))
                      {
                          $users = User::findorFail(auth()->user()->id);
                          $users->password = $this->new_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"]);
                  }
              }