65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Back\Users;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class StoreUserRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|min:3|max:255',
|
|
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
|
'password' => [
|
|
'required',
|
|
'required_with:password_confirmation',
|
|
'confirmed',
|
|
'max:255',
|
|
Password::min(8)
|
|
->letters()
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => trans('validation.attributes.first_name'),
|
|
'email' => trans('validation.attributes.email'),
|
|
'password' => trans('validation.attributes.password'),
|
|
'password.letters' => trans('validation.password.letters'),
|
|
'password.mixed' => trans('validation.password.mixed'),
|
|
'password.numbers' => trans('validation.password.numbers'),
|
|
'password.symbols' => trans('validation.password.symbols'),
|
|
'password.uncompromised' => trans('validation.password.uncompromised'),
|
|
];
|
|
}
|
|
}
|