Files
econom-calculator/app/Http/Requests/UpdateMedicalReportSheetRequest.php
brusnitsyn 3edc8e667e
Some checks failed
tests / ci (8.5) (push) Has been cancelled
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
first commit
2026-04-03 17:20:05 +09:00

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'],
];
}
}