71 lines
3.0 KiB
PHP
71 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Tables;
|
|
|
|
use Filament\Tables\Table;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
class StatistikoPlayersTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('match_id')->searchable(),
|
|
TextColumn::make('ss_player_id')->label('SofaScore Id')->searchable(),
|
|
TextColumn::make('details.player_name')
|
|
->label('Player')
|
|
->searchable()
|
|
->tooltip(fn($record) => $record->details->full_name),
|
|
TextColumn::make('event.home.ss_team_name')->searchable()->color('primary'),
|
|
TextColumn::make('event.away.ss_team_name')->searchable()->color('success'),
|
|
])
|
|
// ->filters([
|
|
// Filter::make('player_filters')
|
|
// ->schema([
|
|
// Checkbox::make('find_double'),
|
|
// ])->query(function (Builder $query, array $data): Builder {
|
|
// return $query->when(
|
|
// $data['find_double'],
|
|
// function (Builder $query) {
|
|
// $arr = [];
|
|
// $events = StatistikoPlayer::query()->select('match_id', 'ss_player_id')->get()->toArray();
|
|
// foreach ($events as $value) {
|
|
// $match_id = $value['match_id'];
|
|
// $player_id = $value['ss_player_id'];
|
|
|
|
// if (isset($arr[$match_id]) && in_array($player_id, $arr[$match_id])) {
|
|
// return $query->where('match_id', $match_id)->where('ss_player_id', $player_id);
|
|
// }
|
|
// $arr[$match_id][] = $player_id;
|
|
// }
|
|
|
|
// return $query->where('match_id', 0);
|
|
// }
|
|
// );
|
|
// })->indicateUsing(function (array $data): ?string {
|
|
// if (! $data['find_double']) {
|
|
// return null;
|
|
// }
|
|
// return 'Find Double';
|
|
// }),
|
|
|
|
// ], layout: FiltersLayout::AboveContent)
|
|
->emptyStateHeading('No player double in an event')
|
|
->deferFilters(false)
|
|
->recordActions([
|
|
EditAction::make()->iconButton(),
|
|
DeleteAction::make()->iconButton(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|