62 lines
2.2 KiB
PHP
62 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Multilines\Tables;
|
|
|
|
use App\Filament\Tables\Columns\BookmakerIcon;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Enums\FiltersLayout;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class MultilinesTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->reorderRecordsTriggerAction(
|
|
fn (Action $action, bool $isReordering) => $action
|
|
->button()
|
|
->label($isReordering ? 'Disable reordering' : 'Enable reordering'),
|
|
)
|
|
->reorderable('sort')
|
|
->defaultGroup('bettype.name')
|
|
->columns([
|
|
IconColumn::make('sport.icon')
|
|
->label('')
|
|
->width('1rem')
|
|
->icon(function ($record): string {
|
|
return $record->sport->icon;
|
|
}),
|
|
TextColumn::make('sport.name'),
|
|
TextColumn::make('matchpart.name'),
|
|
TextColumn::make('bettype.name'),
|
|
TextColumn::make('bookmaker.name'),
|
|
BookmakerIcon::make('bookmaker.icon')->label('Icon'),
|
|
])
|
|
->defaultSort('sort')
|
|
->deferFilters(false)
|
|
->filters([
|
|
SelectFilter::make('sport_id')
|
|
->label('Sport')
|
|
->default(1)
|
|
->selectablePlaceholder(false)
|
|
->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1))
|
|
->preload(),
|
|
], FiltersLayout::AboveContent)
|
|
->hiddenFilterIndicators()
|
|
->persistFiltersInSession()
|
|
->recordActions([
|
|
// EditAction::make()
|
|
// ->mutateDataUsing(function (array $data): array {
|
|
// $data['client_id'] = auth()->user()->client_id;
|
|
|
|
// return $data;
|
|
// }),
|
|
]);
|
|
}
|
|
}
|