47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateAccountRequest 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
|
|
{
|
|
$method = $this->method();
|
|
if ($method == 'PUT') {
|
|
return [
|
|
'name' => ['required'],
|
|
'email' => ['required', 'email'],
|
|
'phone' => ['required'],
|
|
'dob' => ['required'],
|
|
'role' => ['required', Rule::in(['patient', 'doctor', 'admin'])],
|
|
'password' => ['required'],
|
|
];
|
|
} else {
|
|
return [
|
|
'name' => ['sometimes', 'required'],
|
|
'email' => ['sometimes', 'required', 'email'],
|
|
'phone' => ['sometimes', 'required'],
|
|
'dob' => ['sometimes', 'required'],
|
|
'role' => ['sometimes', 'required', Rule::in(['patient', 'doctor', 'admin'])],
|
|
'password' => ['sometimes', 'required'],
|
|
];
|
|
}
|
|
}
|
|
}
|