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

+50 -32
View File
@@ -15,6 +15,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;
@@ -94,41 +95,58 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->defaultPaginationPageOption(10)
->filters([
Filter::make('events')
->columns(4)
->schema([
Select::make('country_id')
->placeholder('Country')
->hiddenLabel()
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
FusedGroup::make([
Select::make('country_id')
->placeholder('Country')
->hiddenLabel()
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->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')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function (Get $get) {
return CompetitionGroup::where('sport_id', auth()->user()->sport_id)
->whereHas('event', function ($query) {
$query->where('starttime', '>', now())
->where('betradar_id', 0);
})
->orderBy('name')
->pluck('name', 'id');
})
->live(),
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
})
->live(),
Select::make('competition_group_id')
->placeholder('League')
->hiddenLabel()
->label('')
->searchable()
->options(function (Get $get) {
$map = Country::all()->pluck('name', 'id');
$query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
->whereHas('event', function ($query) {
$query->where('starttime', '>', now())
->where('betradar_id', 0);
});
if ($get('country_id') ?? null) {
$res = $query->where('country_id', $get('country_id'))->get();
} else {
$res = $query->get();
}
$arr = [];
foreach ($res as $value) {
if (isset($map[$value->country_id])) {
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
} else {
$arr[$value->id] = $value->name;
}
}
asort($arr);
return $arr;
})
->live(),
])->columnSpan(2),
DateRangePicker::make('starttime_period')
->columnSpan(2)
->displayFormat('d M Y')
->columnSpan(2)
->minDate(now())
->hiddenLabel()
->label('')
@@ -144,7 +162,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
function (Builder $query, $competition_group_id) {
$this->setPage(1);
return $query->whereIn('competition_group_id', $competition_group_id);
return $query->where('competition_group_id', $competition_group_id);
}
)->when(
$data['starttime_period'],