ldc-tregalette/app/Http/Requests/Fo/Customers/UpdatePasswordRequest.php

55 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-12-15 15:53:55 +00:00
<?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
*/
2024-01-26 16:24:14 +01:00
public function authorize(): bool
2023-12-15 15:53:55 +00:00
{
return auth('frontend')->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
2024-01-26 16:24:14 +01:00
public function rules(): array
2023-12-15 15:53:55 +00:00
{
2024-01-26 16:24:14 +01:00
/** @var \LDC\LDCCRM\Models\Customer */
2023-12-15 15:53:55 +00:00
$crmCustomer = \auth('frontend')->user()->api_data;
return [
'old_password' => [
'required',
new CrmCustomerPassword($crmCustomer)
],
2024-01-26 16:24:14 +01:00
'password' => [
2023-12-15 15:53:55 +00:00
'required', 'string', 'max:255', 'confirmed',
Password::min(8)->mixedCase()->letters()->numbers()->uncompromised()
]
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
2024-01-26 16:24:14 +01:00
public function attributes(): array
2023-12-15 15:53:55 +00:00
{
return [
'old_password' => trans('ancien mot de passe'),
'password' => trans('mot de passe'),
];
}
}