filter events on same line

This commit is contained in:
salam committed 2026-03-12 11:26:17 +01:00
1 parent 575330ea17
commit 75b587d133
1 file changed
+52 -56
@@ -28,7 +28,6 @@ use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\VerticalAlignment; use Filament\Support\Enums\VerticalAlignment;
use Filament\Support\Enums\Width; use Filament\Support\Enums\Width;
@@ -185,65 +184,62 @@ class EventsTable
Hidden::make('filter_stars'), Hidden::make('filter_stars'),
Hidden::make('filter_notes'), Hidden::make('filter_notes'),
Hidden::make('filter_periode'), Hidden::make('filter_periode'),
FusedGroup::make([ Select::make(name: 'country_id')
Select::make(name: 'country_id') ->placeholder('Country')
->placeholder('Country') ->prefixIcon('phosphor-flag')
->prefixIcon('phosphor-flag') ->hiddenLabel()
->hiddenLabel() ->label('')
->label('') ->multiple()
->multiple() ->searchable()
->searchable() ->preload()
->preload() ->options(function () {
->options(function () { $res = Event::where('has_markets', 1)
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', Carbon::now())
->groupBy('country_id')
->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
}),
Select::make('competition_group_id')
->placeholder('League')
->prefixIcon('phosphor-trophy')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::where('has_markets', 1) $res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id) ->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', Carbon::now()) ->where('starttime', '>', Carbon::now())
->groupBy('country_id') ->whereIn('country_id', $get('country_id'))
->pluck('country_id')->toArray(); ->groupBy('competition_group_id')->get();
} else {
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->groupBy('competition_group_id')->get();
}
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); $arr = [];
}) foreach ($res as $val) {
->live() $arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name;
->reactive() }
->afterStateUpdated(function (callable $set) { asort($arr);
$set('competition_group_id', null);
}),
Select::make('competition_group_id')
->placeholder('League')
->prefixIcon('phosphor-trophy')
->columnSpan(2)
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->whereIn('country_id', $get('country_id'))
->groupBy('competition_group_id')->get();
} else {
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->groupBy('competition_group_id')->get();
}
$arr = []; return $arr;
foreach ($res as $val) { })
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name; ->live(),
}
asort($arr);
return $arr;
})
->live(),
])->hidden(fn () => auth()->user()->sport_id == 5)->columnSpan(2),
Select::make('competition_group_id') Select::make('competition_group_id')
->visible(fn () => auth()->user()->sport_id == 5) ->visible(fn () => auth()->user()->sport_id == 5)
->placeholder('Tournament') ->placeholder('Tournament')