complete Complete User Request Submission section RAD-1

This commit is contained in:
2026-01-03 19:14:30 +03:30
commit 7137ec5792
393 changed files with 152602 additions and 0 deletions
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Enums\DocumentStatusEnum;
use App\Enums\DocumentPriorityEnum;
class DocumentRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'modality' => ['nullable', 'string', 'max:255'],
'status' => ['nullable', 'string', 'max:255' , Rule::in(DocumentStatusEnum::keys())],
'priority' => ['nullable', 'string', 'max:255' , Rule::in(DocumentPriorityEnum::keys())],
'note' => ['nullable', 'string', 'max:255'],
'pet_id' => ['required', 'exists:pets,id'],
'submitted_at' => ['nullable', 'date'],
'scan_date' => ['nullable', 'date'],
'processing_deadline' => ['nullable', 'date'],
'primary_files' => ['nullable', 'array'],
'history_files' => ['nullable', 'array'],
];
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Enums\PetTypeEnum;
use App\Enums\PetGenderEnum;
use App\Support\Converters\PersianToEnglish;
class PetRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'type' => ['required', 'string', 'max:255', Rule::in(PetTypeEnum::values())],
'gender' => ['required', 'string', 'max:255', Rule::in(PetGenderEnum::values())],
'breed' => ['required', 'string', 'max:255'],
'weight' => ['required', 'integer'],
'sterilized' => ['required', 'boolean'],
'birthday' => ['required', 'date'],
];
}
public function prepareForValidation()
{
$this->merge([
'weight' => PersianToEnglish::toEnglish($this->weight),
]);
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Enums\ReportStatusEnum;
class ReportRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'document_id' => ['required', 'exists:documents,id'],
'doctor_id' => ['required', 'exists:users,id'],
'medium_id' => ['nullable', 'exists:media,id'],
'status' => ['required', 'string', 'max:255' , Rule::in(ReportStatusEnum::keys())],
'body' => ['required', 'string'],
'submitted_at' => ['required', 'date'],
];
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class SettingProfileRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$toBeEditedUser = $this->route('user');
return [
'name' => ['required', 'max:255',
isset($toBeEditedUser)
? Rule::unique('users', 'name')->ignore($toBeEditedUser->id)
: Rule::unique('users', 'name')],
'first_name' => 'nullable | max:255',
'last_name' => 'nullable | max:255',
];
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Admin;
use App\Enums\UserEnum;
use App\Rules\PhoneNumber;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UserRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$toBeEditedUser = $this->route()->parameter('user');
return [
'username' => ['nullable', 'min:2', 'max:255',
isset($toBeEditedUser)
? Rule::unique('users')->ignore($toBeEditedUser->id)
: Rule::unique('users')],
'phone' => ['required', 'max:255', new PhoneNumber],
'fullname' => 'nullable | max:255',
'role' => ['nullable', 'array', 'exists:roles,id'],
'profile_url' => ['nullable', 'exists:medium,url'],
'email' => ['nullable', 'email', 'max:255',
isset($toBeEditedUser)
? Rule::unique('users')->ignore($toBeEditedUser->id)
: Rule::unique('users')],
'password' => [isset($toBeEditedUser) ? 'nullable' : 'required', 'min:8' , 'confirmed'],
'level' => ['required', Rule::in(['مدیر' , 'پزشک' , 'سرپرست'])],
];
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests\Client\Auth;
use App\Rules\PhoneNumber;
use Illuminate\Foundation\Http\FormRequest;
class UserRegistrationRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'phone' => ['required', 'string', new PhoneNumber],
'fullname' => 'nullable|string|max:255',
'national_code' => 'required|string|max:255',
'specialty' => 'nullable|string|max:255',
'clinic_name' => 'nullable|string|max:255',
'clinic_phone' => 'nullable|string|max:255',
'province' => 'nullable|string|max:255',
'city' => 'nullable|string|max:255',
'address' => 'nullable|string|max:255',
'level' => 'nullable|string|max:50',
];
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\Client\Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class VerifyOtpRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'otp_code' => [
'required',
'numeric',
'digits:4',
Rule::exists('otp_codes', 'code')->where(function ($query) {
$query->where('phone', session('login_phone'))
->where('expires_at', '>', now());
})
]
];
}
}