ldc-tregalette/app/Http/Requests/Fo/Customers/UpdatePasswordRequest.php
2024-01-30 12:30:24 +01:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Fo\Customers;
use App\Rules\CrmCustomerPassword;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Password;
class UpdatePasswordRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth('frontend')->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
/** @var \LDC\LDCCRM\Models\Customer */
$crmCustomer = \auth('frontend')->user()->api_data;
return [
'old_password' => [
'required',
new CrmCustomerPassword($crmCustomer)
],
'password' => [
'required', 'string', 'max:255', 'confirmed',
Password::min(8)->mixedCase()->letters()->numbers()->uncompromised()
]
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'old_password' => trans('ancien mot de passe'),
'password' => trans('mot de passe'),
];
}
}