Profile Edit

You have the option to edit the current logged in user's profile information (name, email, profile picture) and password. To access this page, just click the "Examples/Profile" link in the left sidebar or add /profile in the URL.

The App\Http\Controllers\ProfileController handles the update of the user information.

          
            public function update(ProfileRequest $request)
            {
                auth()->user()->update(
                    $request->merge(['picture' => $request->photo ? $request->photo->store('profile', 'public') : null])
                        ->except([$request->hasFile('photo') ? '' : 'picture'])
                );

                return back()->withStatus(__('Profile successfully updated.'));
            }

            /**
            * Change the password
            *
            * @param  \App\Http\Requests\PasswordRequest  $request
            * @return \Illuminate\Http\RedirectResponse
            */
            public function password(PasswordRequest $request)
            {
              auth()->user()->update(['password' => Hash::make($request->get('password'))]);

              return back()->withPasswordStatus(__('Password successfully updated.'));
            }
          
        

If you input the wrong data when editing the profile, don`t worry. Validation rules have been added to prevent this (see App\Http\Requests\ProfileRequest). If you try to change the password, you will see that additional validation rules have been added in App\Http\Requests\PasswordRequest. You also have a custom validation rule that can be found in App\Rules\CurrentPasswordCheckRule.

          
            public function rules()
            {
                return [
                    'old_password' => ['required', 'min:6', new CurrentPasswordCheckRule],
                    'password' => ['required', 'min:6', 'confirmed', 'different:old_password'],
                    'password_confirmation' => ['required', 'min:6'],
                ];
            }