first commit
This commit is contained in:
41
app/Http/Requests/UpdateMedicalReportSheetRequest.php
Normal file
41
app/Http/Requests/UpdateMedicalReportSheetRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Support\MedicalReport\TemplateWorkbook;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateMedicalReportSheetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var TemplateWorkbook $templateWorkbook */
|
||||
$templateWorkbook = app(TemplateWorkbook::class);
|
||||
$departmentKeys = array_map(
|
||||
fn (array $department): string => $department['key'],
|
||||
$templateWorkbook->departments(),
|
||||
);
|
||||
|
||||
return [
|
||||
'department' => ['required', 'string', Rule::in($departmentKeys)],
|
||||
'sheet' => ['required', 'string', Rule::in($templateWorkbook->sheetKeys())],
|
||||
'values' => ['required', 'array'],
|
||||
'values.*' => ['nullable', 'string', 'max:255'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user