mapper wip

This commit is contained in:
salam committed 2026-02-13 13:33:17 +01:00
1 parent 1af6eec5e9
commit 35a6e605b9
4 files changed
+118 -85

No files matched your search

+58 -53
View File
@@ -13,6 +13,7 @@ use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
@@ -90,60 +91,64 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->filters([
Filter::make('events')
->schema([
Select::make('country_id')
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
// ->multiple()
->live()
->options(function (Get $get) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray();
})
->reactive()
->afterStateUpdated(function (callable $set) {
$set('group_id', null);
})
->placeholder('Country'),
Select::make('group_cc')
->visible(fn () => auth()->user()->provider_id == 2)
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
// ->multiple()
->live()
->options(function () {
$res = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray();
FusedGroup::make([
Select::make('country_id')
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
->live()
->options(function (Get $get) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray();
})
->afterStateUpdated(function (callable $set) {
$set('group_id', null);
})
->placeholder('Country'),
Select::make('group_cc')
->visible(fn () => auth()->user()->provider_id == 2)
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
->live()
->options(function (Get $get) {
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc');
if ($get('country_id') ?? null) {
$res = $query->where('country_id', $get('country_id'))->pluck('group_cc')->toArray();
} else {
$res = $query->pluck('group_cc')->toArray();
}
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
})
->reactive()
->afterStateUpdated(function (callable $set) {
$set('group_id', null);
})
->placeholder('Country'),
Select::make('group_id')
->placeholder('League')
->label('Leagues')
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
->options(function (Get $get) {
if ($get('country_id')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('country_id', $get('country'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} elseif ($get('group_cc')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} else {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
}
})
->live(),
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
})
->reactive()
->afterStateUpdated(function (callable $set) {
$set('group_id', null);
})
->placeholder('Country'),
Select::make('group_id')
->placeholder('League')
->label('Leagues')
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
->options(function (Get $get) {
if ($get('country_id')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('country_id', $get('country_id'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} elseif ($get('group_cc')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} else {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
}
})
->live(),
])->columnSpan(2),
DateRangePicker::make('starttime_period')
->columnSpan(2)
->displayFormat('d M Y')