-
app/Rules/PasswordCheckRule.php
Open in GitHubuse App\Models\User; use Illuminate\Contracts\Validation\Rule; use Illuminate\Support\Facades\Hash; class PasswordCheckRule implements Rule { // public function passes($attribute, $password) { return Hash::check($password, $this->user->password); } public function message() { return trans('validation.password_check'); } }
-
app/Http/Livewire/Profile/UpdatePassword.php
Open in GitHubuse App\Rules\PasswordCheckRule; use App\Rules\PasswordRule; use Livewire\Component; class UpdatePassword extends Component { // private function validationRules() { return [ 'newPassword' => [ new PasswordRule($this->newPasswordConfirmation), ], 'currentPassword' => [ 'required', new PasswordCheckRule($this->user), ], ]; } // }