complete Complete User Request Submission section RAD-1
This commit is contained in:
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(['مدیر' , 'پزشک' , 'سرپرست'])],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user