dynamic elements and groups
This commit is contained in:
1 parent
80db5b6c6d
commit
0c3142f2fd
42 files changed
+798
-17
No files matched your search
@@ -2,9 +2,22 @@
|
||||
|
||||
namespace App\Filament\Resources\CompetitionGroups\Tables;
|
||||
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
use App\Models\Country;
|
||||
use App\Models\ElementGroup;
|
||||
use App\Models\Event;
|
||||
use App\Models\Group;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CompetitionGroupsTable
|
||||
@@ -27,7 +40,8 @@ class CompetitionGroupsTable
|
||||
->color('gray')
|
||||
->label('Event')
|
||||
->icon(fn ($record) => $record->country->icon),
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
SelectColumn::make('level')
|
||||
->width(30)
|
||||
->options([
|
||||
@@ -35,6 +49,37 @@ class CompetitionGroupsTable
|
||||
'MEDIUM' => 'MEDIUM',
|
||||
'LOW' => 'LOW',
|
||||
]),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')->toArray()),
|
||||
SelectFilter::make('country_id')
|
||||
->searchable()
|
||||
->label('Countries')
|
||||
->options(fn () => Country::orderBy('name')->pluck('name', 'id')->toArray()),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->tooltip('All elements connected to this group, including active events, will be deleted')
|
||||
->before(function ($record) {
|
||||
Group::where('competition_group_id', $record->id)->delete();
|
||||
Event::where('competition_group_id', $record->id)->delete();
|
||||
ElementGroup::where('competition_group_id', $record->id)->delete();
|
||||
CompetitionGroupProvider::where('competition_group_id', $record->id)->delete();
|
||||
})
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Group deleted')
|
||||
->body('The group and all relations has been deleted successfully.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user