From 63edd88bbb7f69b7a28370de953c817f13bc00c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Fri, 15 Dec 2023 14:53:08 +0000 Subject: [PATCH] wip --- .../EditBeneficiaryPersonalInformation.php | 45 +++++++++++++++++++ app/Models/Beneficiary.php | 9 +++- database/factories/BeneficiaryFactory.php | 9 ++++ database/factories/OrganizationFactory.php | 5 ++- ...1_20_130401_create_beneficiaries_table.php | 6 +++ lang/ro/field.php | 5 +++ 6 files changed, 77 insertions(+), 2 deletions(-) diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php index 5a633ed9..4e8e4931 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php @@ -48,6 +48,8 @@ public static function getPersonalInformationFormSchema(): array ->maxWidth('3xl') ->schema([ static::beneficiarySection(), + static::aggressorSection(), + static::antecedentsSection(), ]), ]; } @@ -267,4 +269,47 @@ protected static function aggressorSection(): Section ]), ]); } + + protected static function antecedentsSection(): Section + { + return Section::make(__('beneficiary.section.personal_information.section.antecedents')) + ->columns() + ->schema([ + Grid::make() + ->schema([ + Select::make('has_police_reports') + ->label(__('field.has_police_reports')) + ->placeholder(__('placeholder.select_one')) + ->options(Ternary::options()) + ->enum(Ternary::class) + ->live(), + + TextInput::make('police_report_count') + ->label(__('field.police_report_count')) + ->placeholder(__('placeholder.number')) + ->visible(fn (Get $get) => Ternary::isYes($get('has_police_reports'))) + ->numeric() + ->minValue(0) + ->maxValue(999), + ]), + + Grid::make() + ->schema([ + Select::make('has_medical_reports') + ->label(__('field.has_medical_reports')) + ->placeholder(__('placeholder.select_one')) + ->options(Ternary::options()) + ->enum(Ternary::class) + ->live(), + + TextInput::make('medical_report_count') + ->label(__('field.medical_report_count')) + ->placeholder(__('placeholder.number')) + ->visible(fn (Get $get) => Ternary::isYes($get('has_medical_reports'))) + ->numeric() + ->minValue(0) + ->maxValue(999), + ]), + ]); + } } diff --git a/app/Models/Beneficiary.php b/app/Models/Beneficiary.php index 6d10f344..09829ba4 100644 --- a/app/Models/Beneficiary.php +++ b/app/Models/Beneficiary.php @@ -90,6 +90,11 @@ class Beneficiary extends Model 'income', 'elder_care_count', 'homeownership', + + 'has_police_reports', + 'police_report_count', + 'has_medical_reports', + 'medical_report_count', ]; protected $casts = [ @@ -103,11 +108,13 @@ class Beneficiary extends Model 'children' => 'collection', 'civil_status' => CivilStatus::class, 'criminal_history' => Ternary::class, + 'doesnt_have_children' => 'boolean', 'effective_residence_environment' => ResidenceEnvironment::class, 'elder_care_count' => 'integer', 'gender' => Gender::class, - 'doesnt_have_children' => 'boolean', 'has_family_doctor' => Ternary::class, + 'has_medical_reports' => Ternary::class, + 'has_police_reports' => Ternary::class, 'homeownership' => HomeOwnership::class, 'income' => Income::class, 'legal_residence_environment' => ResidenceEnvironment::class, diff --git a/database/factories/BeneficiaryFactory.php b/database/factories/BeneficiaryFactory.php index a29af642..f382e58e 100644 --- a/database/factories/BeneficiaryFactory.php +++ b/database/factories/BeneficiaryFactory.php @@ -127,7 +127,16 @@ public function withChildren(): static 'status' => fake()->boolean() ? fake()->words(asText: true) : null, ]) ->toJson(), + ]); + } + public function withAntecedents(): static + { + return $this->state(fn (array $attributes) => [ + 'has_police_reports' => fake()->boolean(), + 'police_report_count' => fake()->numberBetween(0, 300), + 'has_medical_reports' => fake()->boolean(), + 'medical_report_count' => fake()->numberBetween(0, 300), ]); } diff --git a/database/factories/OrganizationFactory.php b/database/factories/OrganizationFactory.php index af9f3cb7..c19992a2 100644 --- a/database/factories/OrganizationFactory.php +++ b/database/factories/OrganizationFactory.php @@ -66,6 +66,7 @@ public function configure(): static ->count(5) ->withContactNotes() ->withChildren() + ->withAntecedents() ->for($organization) ->create(); @@ -81,6 +82,7 @@ public function configure(): static ->for($organization) ->withID() ->withChildren() + ->withAntecedents() ->create(); Beneficiary::factory() @@ -95,6 +97,7 @@ public function configure(): static ->for($organization) ->withEffectiveResidence() ->withChildren() + ->withAntecedents() ->create(); Beneficiary::factory() @@ -102,7 +105,7 @@ public function configure(): static ->for($organization) ->withLegalResidence() ->withEffectiveResidence() - ->withChildren() + ->withAntecedents() ->create(); Service::query() diff --git a/database/migrations/2023_11_20_130401_create_beneficiaries_table.php b/database/migrations/2023_11_20_130401_create_beneficiaries_table.php index d0af695e..1178f0db 100644 --- a/database/migrations/2023_11_20_130401_create_beneficiaries_table.php +++ b/database/migrations/2023_11_20_130401_create_beneficiaries_table.php @@ -102,6 +102,12 @@ public function up(): void $table->tinyInteger('elder_care_count')->unsigned()->nullable(); $table->string('homeownership')->nullable(); + + $table->string('has_police_reports')->nullable(); + $table->smallInteger('police_report_count')->unsigned()->nullable(); + + $table->string('has_medical_reports')->nullable(); + $table->smallInteger('medical_report_count')->unsigned()->nullable(); }); } }; diff --git a/lang/ro/field.php b/lang/ro/field.php index 9ca0abe6..91acc235 100644 --- a/lang/ro/field.php +++ b/lang/ro/field.php @@ -109,4 +109,9 @@ 'aggressor_legal_history' => 'Aspecte legale agresor', 'has_protection_order' => 'Ordin de protecție', 'protection_order_notes' => 'Observații ordin de protecție', + + 'has_police_reports' => 'Sesizare la poliție', + 'police_report_count' => 'Număr sesizări', + 'has_medical_reports' => 'Certificate medico-legale', + 'medical_report_count' => 'Număr certificate', ];