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