D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
lactobokashi.com
/
app
/
Http
/
Requests
/
Filename :
ChangePasswordRequest.php
back
Copy
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Hash; class ChangePasswordRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize(): bool { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'old_password' => 'required|string|min:6', 'new_password' => 'required|string|min:6|required_with:confirm_password|same:confirm_password', 'confirm_password' => 'required|string|min:6', ]; } public function withValidator($validator) { $validator->after(function ($validator) { if (!$this->checkOldPassword()) { $validator->errors()->add('old_password', 'The old password does not match.'); } }); } public function checkOldPassword() { return Hash::check(request('old_password'), auth()->user()->password); } }