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
+45 -42
@@ -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) {