git add .
git commit "add user authentication"
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
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',
|
||||
'max:255'
|
||||
],
|
||||
|
||||
'last_name' => [
|
||||
'required',
|
||||
'persian_alpha',
|
||||
'string',
|
||||
'max:255'
|
||||
],
|
||||
|
||||
'national_code' => [
|
||||
'required',
|
||||
'unique:users,national_code',
|
||||
// 'ir_national_id'
|
||||
],
|
||||
|
||||
'gender' => [
|
||||
'required',
|
||||
'in:0,1'
|
||||
],
|
||||
|
||||
'marital_status' => [
|
||||
'required',
|
||||
'in:0,1,2'
|
||||
],
|
||||
|
||||
'spouse_name' => [
|
||||
'nullable'
|
||||
],
|
||||
|
||||
'mobile' => [
|
||||
'required',
|
||||
'unique:users,mobile',
|
||||
'ir_mobile'
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'unique:users,email',
|
||||
],
|
||||
|
||||
'username' => [
|
||||
'required',
|
||||
'unique:users,username',
|
||||
'regex:/^[A-Za-z0-9]+$/',
|
||||
],
|
||||
'image' => [
|
||||
'nullable',
|
||||
'image',
|
||||
'mimes:jpg,jpeg,png,webp',
|
||||
'max:800',
|
||||
],
|
||||
|
||||
'province_id' => [
|
||||
'nullable',
|
||||
'exists:provinces,id',
|
||||
],
|
||||
|
||||
'city_id' => [
|
||||
'nullable',
|
||||
Rule::exists('cities', 'id')
|
||||
->where(fn ($query) => $query->where('province_id', $this->province_id)),
|
||||
],
|
||||
|
||||
|
||||
'password' => [
|
||||
'required',
|
||||
'confirmed',
|
||||
'min:8'
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user