can('change-password-profile') && Auth::user()->id === $request->user()->id){ $validated = $request->validate([ 'current_password' => ['required', 'current_password'], 'password' => ['required', Password::defaults(), 'confirmed'], ]); $request->user()->update([ 'password' => Hash::make($validated['password']), ]); return back()->with('success', __('Password updated successfully.')); } else{ return back()->with('error', __('Permission denied')); } } }