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\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\VerticalAlignment;
use Filament\Support\Enums\Width;
@@ -185,65 +184,62 @@ class EventsTable
Hidden::make('filter_stars'),
Hidden::make('filter_notes'),
Hidden::make('filter_periode'),
FusedGroup::make([
Select::make(name: 'country_id')
->placeholder('Country')
->prefixIcon('phosphor-flag')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->preload()
->options(function () {
Select::make(name: 'country_id')
->placeholder('Country')
->prefixIcon('phosphor-flag')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->preload()
->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)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', Carbon::now())
->groupBy('country_id')
->pluck('country_id')->toArray();
->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();
}
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')
->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 = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name;
}
asort($arr);
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name;
}
asort($arr);
return $arr;
})
->live(),
])->hidden(fn () => auth()->user()->sport_id == 5)->columnSpan(2),
return $arr;
})
->live(),
Select::make('competition_group_id')
->visible(fn () => auth()->user()->sport_id == 5)
->placeholder('Tournament')