diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 32611d91..1d4c1aa4 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -29,6 +29,7 @@ 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\FontWeight; use Filament\Support\Enums\VerticalAlignment; @@ -187,61 +188,63 @@ class EventsTable Hidden::make('filter_stars'), Hidden::make('filter_notes'), Hidden::make('filter_periode'), - Select::make(name: 'country_id') - ->hidden(fn () => auth()->user()->sport_id == 5) - ->placeholder('Country') - ->prefixIcon('phosphor-flag') - ->hiddenLabel() - ->label('') - ->multiple() - ->searchable() - ->preload() - ->options(function () { - $res = Event::where('sport_id', auth()->user()->sport_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray(); + FusedGroup::make([ + 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') - ->hidden(fn () => auth()->user()->sport_id == 5) - ->placeholder('League') - ->prefixIcon('phosphor-trophy') - ->hiddenLabel() - ->label('') - ->multiple() - ->searchable() - ->options(function (Get $get) { - if ($get('country_id')) { - $res = Event::where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); - } else { - $res = Event::where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->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); + 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)->where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); + } else { + $res = Event::where('has_markets', 1)->where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->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); - return $arr; - }) - ->live(), + return $arr; + }) + ->live(), + ])->hidden(fn () => auth()->user()->sport_id == 5)->columnSpan(2), Select::make('group_id') ->visible(fn () => auth()->user()->sport_id == 5) ->placeholder('Tournament') ->prefixIcon('phosphor-trophy') + ->columnSpan(2) ->hiddenLabel() ->label('') ->multiple() ->searchable() ->options(function (Get $get) { if ($get('country_id')) { - $res = Event::with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get(); + $res = Event::where('has_markets', 1)->with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get(); } else { - $res = Event::with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get(); + $res = Event::where('has_markets', 1)->with('country')->where('sport_id', auth()->user()->sport_id)->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get(); } $arr = []; foreach ($res as $val) {