77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Events\Tables;
|
|
|
|
use App\Filament\Tables\Columns\MultilineClient;
|
|
use Carbon\Carbon;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Support\Enums\FontWeight;
|
|
use Filament\Support\Enums\IconSize;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class EventsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->poll('10s')
|
|
->striped()
|
|
->columns([
|
|
IconColumn::make('sport.icon')
|
|
->label('')
|
|
->width('1rem')
|
|
->size(IconSize::ExtraLarge)
|
|
->icon(fn ($record) => $record->sport->icon)
|
|
->tooltip(fn ($record) => $record->id),
|
|
TextColumn::make('txodds_id')->label('Id')->badge()->copyable()->searchable(),
|
|
TextColumn::make('starttime')
|
|
->label('Start')
|
|
->alignCenter()
|
|
->dateTime('d.m')
|
|
->weight(FontWeight::Bold)
|
|
->description(fn ($state): string => Carbon::createFromDate($state)->format('H:i')),
|
|
TextColumn::make('country.name')
|
|
->color('gray')
|
|
->label('Event')
|
|
->icon(fn ($record) => $record->country->icon)
|
|
->description(fn ($record) => $record->competition_group->name),
|
|
TextColumn::make('home.name')->alignRight()->searchable(),
|
|
TextColumn::make('away.name')->searchable(),
|
|
|
|
MultilineClient::make('id')
|
|
->searchable()
|
|
->label(fn () => view('filament.tables.columns.multiline-labels')),
|
|
|
|
])
|
|
->defaultSort('starttime', 'ASC')
|
|
// ->filters([
|
|
// SelectFilter::make('competition_group_id')
|
|
// ->preload()
|
|
// ->label('League')
|
|
// ->multiple()
|
|
// ->searchable()
|
|
// ->options(function () {
|
|
|
|
// $res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
|
|
// $arr = [];
|
|
// foreach ($res as $val) {
|
|
// $arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name;
|
|
// }
|
|
|
|
// asort($arr);
|
|
|
|
// return $arr;
|
|
// })
|
|
// ->selectablePlaceholder(false),
|
|
// ], layout: FiltersLayout::AboveContent)
|
|
->persistFiltersInSession()
|
|
->recordActions([
|
|
// EditAction::make(),
|
|
// DeleteAction::make()->iconButton(),
|
|
]);
|
|
}
|
|
}
|