mapper new
This commit is contained in:
1 parent
fe7fc0accf
commit
e27bba1644
12 files changed
+179
-107
No files matched your search
+40
-16
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user