mapper new

This commit is contained in:
salam committed 2026-01-20 08:33:20 +01:00
1 parent fe7fc0accf
commit e27bba1644
12 files changed
+179 -107

No files matched your search

-4
View File
@@ -21,12 +21,9 @@ class LoadEvents
}
})->pluck('id')->toArray();
// dd(Auth::user()->sport_id);
$query = Event::query()
->with('home')
->with('away')
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where(function ($query) use ($element_ids) {
$query->orWhereIn('home_id', $element_ids)->orWhereIn('away_id', $element_ids);
@@ -37,7 +34,6 @@ class LoadEvents
->with('home')
->with('away')
->where('betradar_id', 0)
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now());
}
+2 -5
View File
@@ -4,7 +4,6 @@ namespace App\Livewire\Mapper;
use App\Models\Mapper;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
class LoadProvider
{
@@ -15,9 +14,8 @@ class LoadProvider
$searchValues = preg_split('/\s+/', $search_right, -1, PREG_SPLIT_NO_EMPTY);
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id)
->where('provider_id', auth()->user()->provider_id)
->where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('home', 'LIKE', '%'.$value.'%')
@@ -26,9 +24,8 @@ class LoadProvider
});
} else {
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id);
->where('provider_id', auth()->user()->provider_id);
}
}
}
+40 -16
View File
@@ -9,6 +9,7 @@ use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
@@ -74,24 +75,44 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->filters([
Filter::make('events')
->schema([
Select::make('country_id')
->placeholder('Country')
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
->multiple()
->label('')
->columnSpan(2)
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->pluck('name', 'id');
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
->afterStateUpdated(function (callable $set, $livewire) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
$set('country_id', null);
$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()
@@ -100,11 +121,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::query()->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('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', $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();
$comps = CompetitionGroup::with('country')->whereIn('id', $res)->get();
@@ -125,8 +146,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
$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)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
+70 -43
View File
@@ -8,6 +8,7 @@ use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -73,44 +74,66 @@ 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')
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
->columnSpan(2)
->live()
->preload()
->options(function () {
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();
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->live()
->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()
->columnSpan(2)
->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();
->afterStateUpdated(function (callable $set, $livewire) {
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
})
->reactive()
->afterStateUpdated(function (callable $set) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
// $set('country_id', null);
// $set('group_cc', null);
$set('group_id', null);
})
->placeholder('Country'),
}),
// Select::make('country_id')
// ->visible(fn () => in_array(Auth()->user()->provider_id, [3, 4]))
// ->placeholder('Country')
// ->hiddenLabel()
// ->label('')
// ->searchable()
// ->preload()
// ->multiple()
// ->columnSpan(2)
// ->live()
// ->options(function (Get $get) {
// return Mapper::query()->where('sport_id', $get('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()
// ->columnSpan(2)
// ->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();
// 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')
@@ -121,24 +144,28 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->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())->whereIn('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())->whereIn('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();
}
// if ($get('country_id')) {
// return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
// } else
// if ($get('group_cc')) {
// return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
// } else {
// }
return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
})
->live(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->whereIn('country_id', $country_id)
)->when(
$data['group_cc'],
fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
$data['sport_id'],
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
// )->when(
// $data['country_id'],
// fn (Builder $query, $country_id) => $query->whereIn('country_id', $country_id)
// )->when(
// $data['group_cc'],
// fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
)->when(
$data['group_id'],
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)