wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
+115
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Tables;
|
||||
|
||||
use App\Filament\Exports\CompetitionGroupExporter;
|
||||
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\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
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
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->color('primary')
|
||||
->width(30)
|
||||
->icon(fn($record) => $record->sport->icon)
|
||||
->tooltip(fn($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('id')->copyable()->alignCenter()->tooltip('Click to copy')
|
||||
->sortable(),
|
||||
TextColumn::make('name')
|
||||
->sortable()
|
||||
->color('primary')
|
||||
->searchable(),
|
||||
TextColumn::make('country.name')
|
||||
->wrap()
|
||||
->sortable()
|
||||
->color('gray')
|
||||
->label('Country')
|
||||
->icon(fn($record) => $record->country->icon),
|
||||
SelectColumn::make('level')
|
||||
->sortable()
|
||||
->width(30)
|
||||
->options([
|
||||
'TOP' => 'TOP',
|
||||
'MEDIUM' => 'MEDIUM',
|
||||
'LOW' => 'LOW',
|
||||
]),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->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([
|
||||
ActionGroup::make([
|
||||
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.'),
|
||||
),
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->modalHeading('Download Tournaments')
|
||||
->color('warning')
|
||||
->label('Export')
|
||||
->icon('phosphor-download')
|
||||
->modalDescription('This will download the TxOdds tournaments with "sport_id" and "country_id" for the sport selected.')
|
||||
->modalIcon('phosphor-microsoft-excel-logo')
|
||||
->exporter(CompetitionGroupExporter::class)
|
||||
->columnMapping(false)
|
||||
->formats([
|
||||
ExportFormat::Xlsx,
|
||||
ExportFormat::Csv,
|
||||
]),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user