ComparingBookmakerMenu ok
This commit is contained in:
1 parent
be80128226
commit
f59ac10c2a
17 files changed
+272
-317
No files matched your search
@@ -8,7 +8,7 @@ use App\Livewire\Mapper\StoreMapped;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
@@ -26,7 +26,6 @@ use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Lazy;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
@@ -46,6 +45,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
'reload_data_right' => '$refresh',
|
||||
];
|
||||
|
||||
public $user;
|
||||
|
||||
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
|
||||
{
|
||||
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
|
||||
@@ -65,8 +66,10 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
$this->user = User::getUser();
|
||||
|
||||
return $table
|
||||
->query(LoadProvider::load($this->search_right))
|
||||
->query(LoadProvider::load($this->search_right, $this->user))
|
||||
->columns([
|
||||
MapperRightColumn::make('right')->label(''),
|
||||
])->searchable(['home', 'away'])
|
||||
@@ -74,66 +77,44 @@ class MapperRight 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')
|
||||
->visible(fn () => in_array($this->user->provider_id, [3, 4]))
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->columnSpan(2)
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function () {
|
||||
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
|
||||
})
|
||||
->multiple()
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
return Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->user->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, $livewire) {
|
||||
|
||||
$livewire->dispatch('reload_data_left');
|
||||
$livewire->dispatch('reload_data_right');
|
||||
|
||||
// $set('country_id', null);
|
||||
// $set('group_cc', null);
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => $this->user->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->options(function () {
|
||||
$res = Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->user->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray();
|
||||
|
||||
}),
|
||||
// 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'),
|
||||
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')
|
||||
@@ -144,28 +125,24 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->preload()
|
||||
->multiple()
|
||||
->options(function (Get $get) {
|
||||
// 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();
|
||||
if ($get('country_id')) {
|
||||
return Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->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', $this->user->sport_id)->where('provider_id', $this->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', $this->user->sport_id)->where('provider_id', $this->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['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)
|
||||
$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)
|
||||
@@ -199,6 +176,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
$livewire->fill(['tableSearch' => '']);
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->dispatch('reload_data_right');
|
||||
$this->dispatch('reload_data_left');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
@@ -216,21 +194,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
$this->dispatch('reload_data_right');
|
||||
}
|
||||
|
||||
// In the same Table class
|
||||
protected function removeTableFilters(): void
|
||||
{
|
||||
// Custom logic before or after removing filters
|
||||
// Example: Log the action
|
||||
\Log::info('Custom filter removal logic triggered.');
|
||||
|
||||
// Call the parent method to perform the default removal
|
||||
parent::removeTableFilters();
|
||||
|
||||
// Or, if you want full control, you can manually clear:
|
||||
// $this->tableFilters = [];
|
||||
// $this->dispatch('refresh-table');
|
||||
}
|
||||
|
||||
public function rightAction(): Action
|
||||
{
|
||||
return Action::make('right')
|
||||
|
||||
Reference in new issue
Block a user