This commit is contained in:
salam committed 2026-02-03 16:48:02 +01:00
1 parent 8a5db5d6da
commit 368af4b565
16 files changed
+97 -281

No files matched your search

+12 -18
View File
@@ -8,7 +8,6 @@ use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -45,8 +44,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
'refreshMapperRight' => '$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);
@@ -66,10 +63,8 @@ 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, $this->user))
->query(LoadProvider::load($this->search_right, auth()->user()))
->columns([
MapperRightColumn::make('right')->label(''),
])->searchable(['home', 'away'])
@@ -78,17 +73,17 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
Filter::make('events')
->schema([
Select::make('country_id')
->visible(fn () => in_array($this->user->provider_id, [3, 4]))
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
// ->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();
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();
})
->reactive()
->afterStateUpdated(function (callable $set) {
@@ -96,17 +91,17 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
})
->placeholder('Country'),
Select::make('group_cc')
->visible(fn () => $this->user->provider_id == 2)
->visible(fn () => auth()->user()->provider_id == 2)
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
// ->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();
$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');
})
@@ -126,11 +121,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->multiple()
->options(function (Get $get) {
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();
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('country_id', $get('country'))->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();
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('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();
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();
}
})
->live(),
@@ -139,10 +134,10 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
return $query
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->whereIn('country_id', $country_id)
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
)->when(
$data['group_cc'],
fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
fn (Builder $query, $group_cc) => $query->where('group_cc', $group_cc)
)->when(
$data['group_id'],
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
@@ -168,7 +163,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
Action::make('refreshMapperRight')
->hiddenLabel()
->icon('phosphor-x')
->color('danger')
->size(Size::Small)
->action(function (Component $livewire) {
$this->search_right = '';