Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Dec 15, 2023
1 parent 86c995d commit 63edd88
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public static function getPersonalInformationFormSchema(): array
->maxWidth('3xl')
->schema([
static::beneficiarySection(),
static::aggressorSection(),
static::antecedentsSection(),
]),
];
}
Expand Down Expand Up @@ -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),
]),
]);
}
}
9 changes: 8 additions & 1 deletion app/Models/Beneficiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions database/factories/BeneficiaryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
}

Expand Down
5 changes: 4 additions & 1 deletion database/factories/OrganizationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function configure(): static
->count(5)
->withContactNotes()
->withChildren()
->withAntecedents()
->for($organization)
->create();

Expand All @@ -81,6 +82,7 @@ public function configure(): static
->for($organization)
->withID()
->withChildren()
->withAntecedents()
->create();

Beneficiary::factory()
Expand All @@ -95,14 +97,15 @@ public function configure(): static
->for($organization)
->withEffectiveResidence()
->withChildren()
->withAntecedents()
->create();

Beneficiary::factory()
->count(5)
->for($organization)
->withLegalResidence()
->withEffectiveResidence()
->withChildren()
->withAntecedents()
->create();

Service::query()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
};
5 changes: 5 additions & 0 deletions lang/ro/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];

0 comments on commit 63edd88

Please sign in to comment.