137 lines
2.9 KiB
PHP
137 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Auth;
|
|
|
|
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',
|
|
'persian_alpha',
|
|
'string',
|
|
'min:3',
|
|
'max:100',
|
|
// 'regex:/^[\x{0600}-\x{06FF}\x{200C}\s]+$/u',
|
|
],
|
|
|
|
|
|
'last_name' => [
|
|
'required',
|
|
'persian_alpha',
|
|
'string',
|
|
'max:100',
|
|
// 'regex:/^[\x{0600}-\x{06FF}\x{200C}\s]+$/u',
|
|
],
|
|
|
|
|
|
'national_code' => [
|
|
'required',
|
|
// 'ir_national_id',
|
|
'digits:10',
|
|
'unique:users,national_code',
|
|
],
|
|
|
|
|
|
'gender' => [
|
|
'required',
|
|
'integer',
|
|
Rule::in([1, 2]),
|
|
],
|
|
|
|
|
|
'marital_status' => [
|
|
'required',
|
|
'integer',
|
|
Rule::in([1, 2, 3]),
|
|
],
|
|
|
|
|
|
'spouse_name' => [
|
|
'nullable',
|
|
'string',
|
|
'max:200',
|
|
'required_if:marital_status,2',
|
|
// 'regex:/^[\x{0600}-\x{06FF}\x{200C}\s]+$/u',
|
|
],
|
|
|
|
|
|
'mobile' => [
|
|
'required',
|
|
'digits:11',
|
|
'ir_mobile:zero',
|
|
// 'regex:/^09\d{9}$/',
|
|
'unique:users,mobile',
|
|
],
|
|
|
|
|
|
'email' => [
|
|
'required',
|
|
'email',
|
|
'max:150',
|
|
'unique:users,email',
|
|
],
|
|
|
|
|
|
'username' => [
|
|
'required',
|
|
'persian_not_accept',
|
|
'string',
|
|
'min:3',
|
|
'max:50',
|
|
// 'regex:/^[A-Za-z0-9]+$/',
|
|
'unique:users,username',
|
|
],
|
|
|
|
|
|
'password' => [
|
|
'required',
|
|
'string',
|
|
'min:8',
|
|
'confirmed',
|
|
],
|
|
|
|
|
|
'image' => [
|
|
'nullable',
|
|
'image',
|
|
'mimes:jpg,jpeg,png,webp',
|
|
'max:800',
|
|
],
|
|
|
|
|
|
'province_id' => [
|
|
'nullable',
|
|
'integer',
|
|
],
|
|
|
|
|
|
'city_id' => [
|
|
'nullable',
|
|
'integer',
|
|
],
|
|
|
|
|
|
];
|
|
}
|
|
}
|