Skip to content

Commit

Permalink
update vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Sep 30, 2024
1 parent eb5179b commit 5daf982
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/Filament/Resources/CatagraphyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public static function form(Form $form): Form
->label(__('field.evaluation_date'))
->required(),

Checkbox::make('is_social_case')
->label($categories->get('SOC'))
->columnSpanFull(),
]),

Subsection::make()
Expand Down Expand Up @@ -226,6 +229,10 @@ public static function form(Form $form): Form
->multiple()
->searchable(),

Checkbox::make('is_vaccinated_on_schedule')
->label($categories->get('VCC'))
->columnSpanFull(),

Select::make('cat_ssa')
->label($categories->get('SSA'))
->placeholder(__('placeholder.select_many'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ protected function form(Form $form): Form
->schema([
Value::make('evaluation_date')
->label(__('field.evaluation_date')),

VulnerabilityChips::make('cat_soc')
->label($categories->get('SOC'))
->columnSpanFull(),
]),

Subsection::make()
Expand Down Expand Up @@ -119,6 +123,10 @@ protected function form(Form $form): Form
VulnerabilityChips::make('cat_ns')
->label($categories->get('NS')),

VulnerabilityChips::make('cat_vcc')
->label($categories->get('VCC'))
->columnSpanFull(),

VulnerabilityChips::make('cat_ssa')
->label($categories->get('SSA')),

Expand Down
27 changes: 27 additions & 0 deletions app/Models/Catagraphy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Catagraphy extends Model
'has_health_issues',
'cat_ssa',
'cat_vif',
'is_social_case',
'is_vaccinated_on_schedule',
];

protected $casts = [
Expand All @@ -66,6 +68,8 @@ class Catagraphy extends Model
'cat_vif' => 'array',
'has_disabilities' => 'boolean',
'has_health_issues' => 'boolean',
'is_social_case' => 'boolean',
'is_vaccinated_on_schedule' => 'boolean',
];

protected $with = [
Expand Down Expand Up @@ -136,6 +140,7 @@ public function socioeconomicVulnerabilities(): Attribute
{
return Attribute::make(
get: fn () => $this->mapVulnerabilities([
$this->cat_soc,
$this->cat_id,
$this->cat_age,
$this->cat_inc,
Expand Down Expand Up @@ -174,6 +179,28 @@ public function catDiz(): Attribute
)->shouldCache();
}

public function catSoc(): Attribute
{
return Attribute::make(
get: fn () => match ($this->is_social_case) {
true => 'VCS_01',
false => 'VCS_99',
default => null,
},
)->shouldCache();
}

public function catVcc(): Attribute
{
return Attribute::make(
get: fn () => match ($this->is_vaccinated_on_schedule) {
true => 'VVC_01',
false => 'VVC_99',
default => null,
},
)->shouldCache();
}

public function catSs(): Attribute
{
return Attribute::make(
Expand Down
Binary file modified database/data/240722-vulnerabilities.xlsx
Binary file not shown.
2 changes: 2 additions & 0 deletions database/factories/CatagraphyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function definition()

'has_disabilities' => fake()->boolean(),
'has_health_issues' => fake()->boolean(),
'is_social_case' => fake()->boolean(),
'is_vaccinated_on_schedule' => fake()->boolean(),

'cat_age' => fake()->randomElement($this->vulnerabilities->get('AGE')->keys()),
'cat_as' => fake()->randomElement($this->vulnerabilities->get('AS')->keys()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('catagraphies', function (Blueprint $table) {
$table->boolean('is_social_case')->nullable()->after('evaluation_date');
$table->boolean('is_vaccinated_on_schedule')->nullable()->after('cat_ns');
});
}
};

0 comments on commit 5daf982

Please sign in to comment.