ldc-legaulois/app/Http/Requests/Club/Customers/UpdatePasswordRequest.php

55 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2024-07-30 16:05:27 +02:00
<?php
namespace App\Http\Requests\Club\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()
{
return auth('club')->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
/** @var \LDC\LDCCRM\Models\Customer $crmCustomer */
$crmCustomer = \auth('club')->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()
{
return [
'old_password' => trans('validation.custom.old_password'),
'password' => trans('validation.attributes.password'),
];
}
}