feat: add user authentication
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginPostRequest 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 [
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
],
|
||||
|
||||
'password' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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',
|
||||
'string',
|
||||
'max:100',
|
||||
'regex:/^[\x{0600}-\x{06FF}\x{200C}\s]+$/u',
|
||||
],
|
||||
|
||||
|
||||
'last_name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:100',
|
||||
'regex:/^[\x{0600}-\x{06FF}\x{200C}\s]+$/u',
|
||||
],
|
||||
|
||||
|
||||
'national_code' => [
|
||||
'required',
|
||||
'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',
|
||||
'regex:/^09\d{9}$/',
|
||||
'unique:users,mobile',
|
||||
],
|
||||
|
||||
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'max:150',
|
||||
'unique:users,email',
|
||||
],
|
||||
|
||||
|
||||
'username' => [
|
||||
'required',
|
||||
'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',
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user