wip
This commit is contained in:
1 parent
550ea115f1
commit
c036814366
12 files changed
+481
-18891
No files matched your search
@@ -5,27 +5,65 @@ namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class UbEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->poll('10sec')
|
||||
->columns([
|
||||
// TextColumn::make('league_id')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('league.name')->searchable(),
|
||||
// TextColumn::make('home_id')->searchable(),
|
||||
// TextColumn::make('away_id')->searchable(),
|
||||
TextColumn::make('home.name')->searchable(),
|
||||
TextColumn::make('away.name')->searchable(),
|
||||
TextColumn::make('player_id')->searchable(),
|
||||
TextColumn::make('player.name')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('rating'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
Filter::make('created_at')
|
||||
->columns(2)->columnSpanFull()
|
||||
->schema([
|
||||
DatePicker::make('from'),
|
||||
DatePicker::make('until'),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['from'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data['until'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '<=', $date),
|
||||
);
|
||||
})
|
||||
->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['from'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime from '.Carbon::parse($data['from'])->toFormattedDateString())
|
||||
->removeField('from');
|
||||
}
|
||||
|
||||
if ($data['until'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime until '.Carbon::parse($data['until'])->toFormattedDateString())
|
||||
->removeField('until');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user