Skip to content

Commit

Permalink
Merge branch 'main' into 176-teams-contact-perosn-sub-section
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Sep 9, 2024
2 parents 0dc3f5b + 09c6e32 commit 3de2f1c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/Filament/Resources/OrganisationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -244,15 +243,17 @@ 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')
->label(__('organisation.field.resource_types'))
->helperText(__('general.help.multi_select'))
->multiple()
->preload()
->columnSpanFull(),
->columnSpanFull()
->required(),
]),

Section::make(__('organisation.section.area_of_activity'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/OrganisationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __invoke(): JsonResource
'status',
'area',
'contact_person_in_teams',
'description',
'created_at',
'updated_at',
])
Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/OrganisationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions database/factories/OrganisationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion lang/ro/organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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ă.',
],

Expand Down

0 comments on commit 3de2f1c

Please sign in to comment.