diff --git a/app/Filament/Resources/OrganisationResource.php b/app/Filament/Resources/OrganisationResource.php index c8ad72d..f852d05 100644 --- a/app/Filament/Resources/OrganisationResource.php +++ b/app/Filament/Resources/OrganisationResource.php @@ -216,7 +216,8 @@ public static function form(Form $form): Form ->label(__('organisation.field.risk_category')) ->helperText(__('general.help.multi_select')) ->multiple() - ->preload(), + ->preload() + ->required(), Select::make('resource_types') ->relationship('resourceTypes', 'name') @@ -224,7 +225,8 @@ public static function form(Form $form): Form ->helperText(__('general.help.multi_select')) ->multiple() ->preload() - ->columnSpanFull(), + ->columnSpanFull() + ->required(), ]), Section::make(__('organisation.section.area_of_activity')) diff --git a/database/factories/OrganisationFactory.php b/database/factories/OrganisationFactory.php index 0154a84..1916a87 100644 --- a/database/factories/OrganisationFactory.php +++ b/database/factories/OrganisationFactory.php @@ -121,6 +121,9 @@ public function withRelated(): static $organisation->riskCategories() ->attach($this->randomRiskCategories(3)); + $organisation->resourceTypes() + ->attach($this->randomResourceTypes(3)); + if ($organisation->has_branches) { Branch::factory() ->for($organisation) @@ -177,4 +180,11 @@ protected function randomRiskCategories(int $count = 1): Collection ->rememberForever('risk_categories', fn () => RiskCategory::pluck('id')) ->random($count); } + + protected function randomResourceTypes(int $count = 1): Collection + { + return Cache::driver('array') + ->rememberForever('resource_types', fn () => Organisation\ResourceType::pluck('id')) + ->random($count); + } }