user() !== null; } /** * Get the validation rules that apply to the request. * * @return array|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'], ]; } }