filter wip

This commit is contained in:
salam committed 2026-02-16 10:51:03 +01:00
1 parent bbec2fa964
commit 4dd741e60b
1 file changed
+10 -7
@@ -29,6 +29,7 @@ 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\FontWeight; use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\VerticalAlignment; use Filament\Support\Enums\VerticalAlignment;
@@ -187,8 +188,8 @@ 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')
->hidden(fn () => auth()->user()->sport_id == 5)
->placeholder('Country') ->placeholder('Country')
->prefixIcon('phosphor-flag') ->prefixIcon('phosphor-flag')
->hiddenLabel() ->hiddenLabel()
@@ -197,7 +198,7 @@ class EventsTable
->searchable() ->searchable()
->preload() ->preload()
->options(function () { ->options(function () {
$res = Event::where('sport_id', auth()->user()->sport_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray(); $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'); return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
}) })
@@ -207,18 +208,18 @@ class EventsTable
$set('competition_group_id', null); $set('competition_group_id', null);
}), }),
Select::make('competition_group_id') Select::make('competition_group_id')
->hidden(fn () => auth()->user()->sport_id == 5)
->placeholder('League') ->placeholder('League')
->prefixIcon('phosphor-trophy') ->prefixIcon('phosphor-trophy')
->columnSpan(2)
->hiddenLabel() ->hiddenLabel()
->label('') ->label('')
->multiple() ->multiple()
->searchable() ->searchable()
->options(function (Get $get) { ->options(function (Get $get) {
if ($get('country_id')) { 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(); $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 { } else {
$res = Event::where('sport_id', auth()->user()->sport_id)->with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); $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 = []; $arr = [];
foreach ($res as $val) { foreach ($res as $val) {
@@ -229,19 +230,21 @@ class EventsTable
return $arr; return $arr;
}) })
->live(), ->live(),
])->hidden(fn () => auth()->user()->sport_id == 5)->columnSpan(2),
Select::make('group_id') Select::make('group_id')
->visible(fn () => auth()->user()->sport_id == 5) ->visible(fn () => auth()->user()->sport_id == 5)
->placeholder('Tournament') ->placeholder('Tournament')
->prefixIcon('phosphor-trophy') ->prefixIcon('phosphor-trophy')
->columnSpan(2)
->hiddenLabel() ->hiddenLabel()
->label('') ->label('')
->multiple() ->multiple()
->searchable() ->searchable()
->options(function (Get $get) { ->options(function (Get $get) {
if ($get('country_id')) { 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 { } 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 = []; $arr = [];
foreach ($res as $val) { foreach ($res as $val) {