first commit
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

This commit is contained in:
brusnitsyn
2026-04-03 17:20:05 +09:00
commit 3edc8e667e
358 changed files with 39258 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?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 UpsertMedicalReportFormTemplateRequest 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)],
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string', 'max:2000'],
'schema' => ['required', 'array:title,description,sections'],
'schema.title' => ['required', 'string', 'max:255'],
'schema.description' => ['nullable', 'string', 'max:2000'],
'schema.sections' => ['required', 'array', 'min:1'],
'schema.sections.*.key' => ['required', 'string', 'max:100'],
'schema.sections.*.title' => ['required', 'string', 'max:255'],
'schema.sections.*.economist_label' => ['nullable', 'string', 'max:255'],
'schema.sections.*.fields' => ['required', 'array', 'min:1'],
'schema.sections.*.fields.*.key' => ['required', 'string', 'max:100'],
'schema.sections.*.fields.*.label' => ['required', 'string', 'max:255'],
'schema.sections.*.fields.*.type' => ['required', 'string', Rule::in(['text', 'number', 'department-select'])],
'schema.sections.*.export_metrics' => ['nullable', 'array', 'min:1'],
'schema.sections.*.export_metrics.*.key' => ['required', 'string', 'max:100'],
'schema.sections.*.export_metrics.*.label' => ['required', 'string', 'max:255'],
'schema.sections.*.export_metrics.*.source_field' => ['required', 'string', 'max:100'],
'schema.sections.*.export_metrics.*.aggregation' => ['required', 'string', Rule::in(['sum'])],
'schema.sections.*.export_metrics.*.analysis_column' => ['nullable', 'string', 'max:100'],
'schema.sections.*.export_metrics.*.row_mode' => ['nullable', 'string', Rule::in(['entry_department', 'fixed_unit'])],
'schema.sections.*.export_metrics.*.target_unit_slug' => ['nullable', 'string', 'max:255'],
'schema.sections.*.default_entries' => ['nullable', 'array'],
'schema.sections.*.default_entries.*' => ['array'],
];
}
}