diff --git a/app/Filament/Resources/OrganisationResource.php b/app/Filament/Resources/OrganisationResource.php index 286007b..349031c 100644 --- a/app/Filament/Resources/OrganisationResource.php +++ b/app/Filament/Resources/OrganisationResource.php @@ -31,7 +31,6 @@ use Filament\Resources\Resource; use Filament\Resources\Table; use Filament\Tables; -use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Layout; @@ -124,7 +123,7 @@ public static function form(Form $form): Form Textarea::make('description') ->label(__('organisation.field.short_description')) - ->maxLength(1000) + ->maxLength(1500) ->rows(2) ->helperText(__('organisation.help.description')) ->required() @@ -244,7 +243,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') @@ -252,7 +252,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/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php b/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php index 39efc63..e7ace60 100644 --- a/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php +++ b/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php @@ -83,6 +83,14 @@ protected function getActions(): array ->inlineLabel(), ]) + ->mutateFormDataUsing(function (array $data) { + $data['contact_person'] = [ + 'email' => $data['email'], + 'phone' => $data['phone'], + ]; + + return $data; + }) ->successRedirectUrl(fn ($record) => OrganisationResource::getUrl('view', $record)) ->disableCreateAnother(), ]; diff --git a/app/Http/Controllers/OrganisationController.php b/app/Http/Controllers/OrganisationController.php index 5992fd6..0b89aab 100644 --- a/app/Http/Controllers/OrganisationController.php +++ b/app/Http/Controllers/OrganisationController.php @@ -25,6 +25,7 @@ public function __invoke(): JsonResource 'status', 'area', 'contact_person_in_teams', + 'description', 'created_at', 'updated_at', ]) diff --git a/app/Http/Resources/OrganisationResource.php b/app/Http/Resources/OrganisationResource.php index ef6f754..ac0cd48 100644 --- a/app/Http/Resources/OrganisationResource.php +++ b/app/Http/Resources/OrganisationResource.php @@ -27,6 +27,7 @@ public function toArray(Request $request): array 'area' => $this->area, 'county' => $this->county->name, 'activity_counties' => IdAndNameResource::collection($this->activityCounties), + 'description' => $this->description, 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 'updated_at' => $this->updated_at->format('Y-m-d H:i:s'), 'volunteers_count' => (int) $this->volunteers_count, diff --git a/database/factories/OrganisationFactory.php b/database/factories/OrganisationFactory.php index 26a8ae6..f6c3b90 100644 --- a/database/factories/OrganisationFactory.php +++ b/database/factories/OrganisationFactory.php @@ -130,6 +130,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) @@ -186,4 +189,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); + } } diff --git a/lang/ro/organisation.php b/lang/ro/organisation.php index 8ac18d2..6801bae 100644 --- a/lang/ro/organisation.php +++ b/lang/ro/organisation.php @@ -111,7 +111,7 @@ 'help' => [ 'short_description' => 'Descrie organizația ta în 200 - 250 caractere. Descrierea va fi vizibilă în alte aplicații, după caz.', - 'description' => 'Adaugă o descriere a organizației tale (maximum 1000 caractere).', + 'description' => 'Adaugă o descriere a organizației tale (maximum 1500 caractere).', 'logo' => 'Încarcă logo-ul organizației tale, la o calitate cât mai bună.', ],