42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?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'],
|
|
];
|
|
}
|
|
}
|