113 lines
2.8 KiB
PHP
113 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Auth;
|
|
|
|
use App\Enums\User\UserGender;
|
|
use App\Enums\User\UserMarital;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class RegisterPostRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'first_name' => [
|
|
'required',
|
|
'min:3',
|
|
'max:64',
|
|
'string',
|
|
'persian_alpha'
|
|
],
|
|
'last_name' => [
|
|
'required',
|
|
'string',
|
|
'min:3',
|
|
'max:64',
|
|
'persian_alpha'
|
|
],
|
|
'national_code' => [
|
|
'required',
|
|
'string',
|
|
'digits:10',
|
|
'regex:/^[0-9]{10}$/',
|
|
'unique:users,national_code'
|
|
],
|
|
'gender' => [
|
|
'required',
|
|
'integer',
|
|
Rule::enum(UserGender::class),
|
|
],
|
|
'marital_status' => [
|
|
'required',
|
|
'integer',
|
|
Rule::enum(UserMarital::class),
|
|
],
|
|
'spouse_name' => [
|
|
'nullable',
|
|
'string',
|
|
'min:5',
|
|
'max:255',
|
|
'persian_alpha'
|
|
],
|
|
'mobile' => [
|
|
'required',
|
|
'string',
|
|
'ir_mobile:zero'
|
|
],
|
|
'email' => [
|
|
'required',
|
|
'email',
|
|
'max:150',
|
|
'unique:users,email'
|
|
],
|
|
'username' => [
|
|
'required',
|
|
'string',
|
|
'regex:/^[a-zA-Z0-9]+$/',
|
|
'alpha_num',
|
|
'min:8',
|
|
'max:100',
|
|
'unique:users,username'
|
|
],
|
|
'avatar' => [
|
|
'nullable',
|
|
'image',
|
|
'mimes:jpg,png,jpeg,webp',
|
|
'max:800'
|
|
],
|
|
'password' => [
|
|
'required',
|
|
'min:8',
|
|
'max:255',
|
|
'alpha_num',
|
|
'confirmed'
|
|
],
|
|
'province_id' => [
|
|
'nullable',
|
|
'integer',
|
|
'exists:provinces,id'
|
|
],
|
|
'city_id' => [
|
|
'nullable',
|
|
'integer',
|
|
'exists:cities,id'
|
|
]
|
|
];
|
|
}
|
|
}
|