comparing bookmaker wip

This commit is contained in:
salam committed 2026-01-20 18:48:01 +01:00
1 parent de95867692
commit be80128226
11 files changed
+237 -93

No files matched your search

+25 -40
View File
@@ -42,6 +42,8 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public $search_left = false;
public $sport_id = 0;
protected $listeners = [
'reload_data_left' => '$refresh',
];
@@ -65,8 +67,10 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
$this->setSportId();
return $table
->query(LoadEvents::load($this->search_left))
->query(LoadEvents::load($this->search_left, $this->sport_id))
->columns([
MapperLeftColumn::make('left')->label(''),
])
@@ -75,44 +79,23 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->filters([
Filter::make('events')
->schema([
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
Select::make('country_id')
->placeholder('Country')
->hiddenLabel()
->multiple()
->columnSpan(2)
->searchable()
->preload()
->options(function () {
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
$res = Event::query()->where('sport_id', $this->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set, $livewire) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
$set('country_id', null);
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
}),
// Select::make('country_id')
// ->placeholder('Country')
// ->hiddenLabel()
// ->multiple()
// ->columnSpan(2)
// ->searchable()
// ->preload()
// ->options(function (Get $get) {
// $res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
// return Country::query()->whereIn('id', $res)->pluck('name', 'id');
// })
// ->live()
// ->reactive()
// ->afterStateUpdated(function (callable $set) {
// $set('competition_group_id', null);
// }),
Select::make('competition_group_id')
->placeholder('League')
->hiddenLabel()
@@ -121,11 +104,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->multiple()
->searchable()
->options(function (Get $get) {
// if ($get('country_id')) {
// $res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
// } else {
// }
$res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
if ($get('country_id')) {
$res = Event::query()->where('sport_id', $this->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
} else {
$res = Event::query()->where('sport_id', $this->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
}
$comps = CompetitionGroup::with('country')->whereIn('id', $res)->get();
@@ -146,11 +129,8 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['sport_id'],
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
// )->when(
// $data['country_id'],
// fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
$data['country_id'],
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
@@ -192,6 +172,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$this->elements_swopped = ! $this->elements_swopped;
}
public function setSportId()
{
$this->sport_id = Sport::getSportId();
}
#[On('search_left')]
public function searchLeft($str)
{