wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class StatisticFixturesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
IconColumn::make('sport_id')
|
||||
->label('')
|
||||
->icon(fn(string $state): string => match ($state) {
|
||||
'1' => 'icon-soccerball',
|
||||
'2' => 'icon-icehockey',
|
||||
'3' => 'icon-basketball',
|
||||
'5' => 'icon-tennisball',
|
||||
}),
|
||||
IconColumn::make('league.sofascore_category.flag')
|
||||
->label('')
|
||||
->icon(function ($state): string {
|
||||
return $state;
|
||||
}),
|
||||
TextColumn::make('league.name')
|
||||
->label('League')
|
||||
->tooltip(fn($record) => $record->league_id)
|
||||
->sortable()
|
||||
->searchable()
|
||||
->description(
|
||||
fn($record) => $record->league->sofascore_category->name
|
||||
),
|
||||
TextColumn::make('starttime')->dateTime('Y-m-d H:i')
|
||||
->sortable(),
|
||||
TextColumn::make('home.ss_team_name')
|
||||
->tooltip(fn($record) => $record->home_id)
|
||||
->color('primary')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('away.ss_team_name')
|
||||
->tooltip(fn($record) => $record->away_id)
|
||||
->color('success')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('updated_at')->alignCenter()->date(),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('fixture_filters')
|
||||
->columns(3)
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->options(fn() => Sport::query()->where('is_active', 1)->pluck('name', 'id'))
|
||||
->selectablePlaceholder(false)
|
||||
->label('Sport')
|
||||
->live(),
|
||||
Select::make('league_id')
|
||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sport_id')))
|
||||
->preload()
|
||||
->searchable()
|
||||
->columnSpan(2)
|
||||
->label('League'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['league_id'],
|
||||
function (Builder $query, $league_id) {
|
||||
$query->where('league_id', $league_id)->orderBy('league_id');
|
||||
}
|
||||
)->when(
|
||||
$data['sport_id'],
|
||||
function (Builder $query, $away_id) {
|
||||
$query->where('sport_id', (int) $away_id);
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user