first commit
This commit is contained in:
25
app/Http/Requests/Settings/PasswordUpdateRequest.php
Normal file
25
app/Http/Requests/Settings/PasswordUpdateRequest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PasswordUpdateRequest extends FormRequest
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'current_password' => $this->currentPasswordRules(),
|
||||
'password' => $this->passwordRules(),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Settings/ProfileDeleteRequest.php
Normal file
24
app/Http/Requests/Settings/ProfileDeleteRequest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProfileDeleteRequest extends FormRequest
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => $this->currentPasswordRules(),
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Requests/Settings/ProfileUpdateRequest.php
Normal file
22
app/Http/Requests/Settings/ProfileUpdateRequest.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Concerns\ProfileValidationRules;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
use ProfileValidationRules;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return $this->profileRules($this->user()->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Laravel\Fortify\InteractsWithTwoFactorState;
|
||||
|
||||
class TwoFactorAuthenticationRequest extends FormRequest
|
||||
{
|
||||
use InteractsWithTwoFactorState;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Support\MedicalReport\StructuredTemplateRegistry;
|
||||
use App\Support\MedicalReport\TemplateWorkbook;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateMedicalReportStructuredTemplateRequest 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);
|
||||
/** @var StructuredTemplateRegistry $structuredTemplateRegistry */
|
||||
$structuredTemplateRegistry = app(StructuredTemplateRegistry::class);
|
||||
$departmentKeys = array_map(
|
||||
fn (array $department): string => $department['key'],
|
||||
$templateWorkbook->departments(),
|
||||
);
|
||||
$reportDepartment = $this->string('department')->toString();
|
||||
$template = $structuredTemplateRegistry->templateForDepartment($reportDepartment);
|
||||
|
||||
$rules = [
|
||||
'department' => ['required', 'string', Rule::in($departmentKeys)],
|
||||
'template_key' => ['required', 'string', Rule::in(array_filter([$template['key'] ?? null]))],
|
||||
];
|
||||
|
||||
if (isset($template['sections']) && is_array($template['sections'])) {
|
||||
$rules['sections'] = ['required', 'array'];
|
||||
|
||||
foreach ($template['sections'] as $section) {
|
||||
$rules['sections.'.$section['key'].'.entries'] = ['nullable', 'array'];
|
||||
|
||||
foreach ($section['fields'] ?? [] as $field) {
|
||||
$rules['sections.'.$section['key'].'.entries.*.'.$field['key']] = $this->fieldRules($field['type'] ?? 'text');
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
$rules['entries'] = ['required', 'array'];
|
||||
|
||||
foreach ($template['fields'] ?? [] as $field) {
|
||||
$rules['entries.*.'.$field['key']] = $this->fieldRules($field['type'] ?? 'text');
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, ValidationRule|string>
|
||||
*/
|
||||
private function fieldRules(string $fieldType): array
|
||||
{
|
||||
return match ($fieldType) {
|
||||
'department-select' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::exists((new Department)->getTable(), 'id'),
|
||||
],
|
||||
'number' => ['required', 'numeric'],
|
||||
default => ['required', 'string', 'max:255'],
|
||||
};
|
||||
}
|
||||
}
|
||||
61
app/Http/Requests/UpsertMedicalReportFormTemplateRequest.php
Normal file
61
app/Http/Requests/UpsertMedicalReportFormTemplateRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user