From 60b524012de9641f153d6b87b95f3fbeff8930f1 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 17 Apr 2026 09:34:49 +0200 Subject: [PATCH] fix swop for mapper --- app/Livewire/Mapper/StoreMapped.php | 2 +- app/Livewire/MapperLeft.php | 20 ++++++----- app/Livewire/MapperRight.php | 34 ++++++++++--------- .../filament/pages/event-mapper.blade.php | 2 +- .../views/livewire/confirm-mapping.blade.php | 23 +++++++------ 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/app/Livewire/Mapper/StoreMapped.php b/app/Livewire/Mapper/StoreMapped.php index 40da2025..4081a19e 100644 --- a/app/Livewire/Mapper/StoreMapped.php +++ b/app/Livewire/Mapper/StoreMapped.php @@ -18,7 +18,7 @@ class StoreMapped $mapper = Mapper::where('event_id', $arguments['event_id'])->first(); - // dd($mapper); + dd($mapper, $arguments, $swopped); /* EVENT diff --git a/app/Livewire/MapperLeft.php b/app/Livewire/MapperLeft.php index 7423c799..4e15b62a 100644 --- a/app/Livewire/MapperLeft.php +++ b/app/Livewire/MapperLeft.php @@ -30,6 +30,7 @@ use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\Indicator; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\Auth; use Livewire\Attributes\On; use Livewire\Component; @@ -51,6 +52,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable public function isRemovingAllFilters() {} + public function swop_elements() + { + $this->elements_swopped = ! $this->elements_swopped; + } + public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void { if (($key = array_search($field, $this->search_values)) !== false) { @@ -99,12 +105,12 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable ->schema([ Select::make('country_id') ->placeholder('Country') - ->visible(fn () => auth()->user()->sport_id != 5) + ->visible(fn () => Auth::user()->sport_id != 5) ->hiddenLabel() ->searchable() ->preload() ->options(function (Get $get) { - $query = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->groupBy('country_id'); + $query = Event::query()->where('sport_id', Auth::user()->sport_id)->where('betradar_id', 0)->groupBy('country_id'); $timeframe = $get('starttime_period') ?? []; @@ -140,7 +146,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable ->searchable() ->options(function (Get $get) { - $query = CompetitionGroup::where('sport_id', auth()->user()->sport_id) + $query = CompetitionGroup::where('sport_id', Auth::user()->sport_id) ->whereHas('event', function ($query) { $query->where('betradar_id', 0); }); @@ -169,7 +175,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable } }); } - if (auth()->user()->sport_id != 5) { + if (Auth::user()->sport_id != 5) { $res = $query->groupBy('country_id')->get(); } else { $res = $query->get(); @@ -271,11 +277,6 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable ]); } - public function toggle() - { - $this->elements_swopped = ! $this->elements_swopped; - } - #[On('search_left')] public function searchLeft($string) { @@ -328,6 +329,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable public function render() { + return view('livewire.mapper-left'); } } diff --git a/app/Livewire/MapperRight.php b/app/Livewire/MapperRight.php index 193978e5..9ff3792b 100644 --- a/app/Livewire/MapperRight.php +++ b/app/Livewire/MapperRight.php @@ -31,6 +31,7 @@ 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\On; use Livewire\Component; @@ -50,6 +51,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable 'refreshMapperRight' => '$refresh', ]; + public function swop_elements() + { + $this->elements_swopped = ! $this->elements_swopped; + } + public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void { if (($key = array_search($field, $this->search_values)) !== false) { @@ -84,9 +90,9 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable IconColumn::make('country_magloo.icon') ->label('') ->icon(fn (string $state): string => $state) - ->visible(fn () => in_array(auth()->user()->provider_id, [3, 4])), + ->visible(fn () => in_array(Auth::user()->provider_id, [3, 4])), IconColumn::make('group_cc') - ->visible(fn () => auth()->user()->provider_id == 2) + ->visible(fn () => Auth::user()->provider_id == 2) ->icon(fn (string $state): string => 'flag-country-'.$state)->label(''), IconColumn::make('sport.icon') ->label('') @@ -99,7 +105,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable Filter::make('events') ->schema([ Select::make('country_id') - ->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]) && auth()->user()->sport_id != 5) + ->visible(fn () => in_array(Auth::user()->provider_id, [3, 4]) && Auth::user()->sport_id != 5) ->placeholder('Country') ->hiddenLabel() ->label('') @@ -107,7 +113,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->preload() ->live() ->options(function (Get $get) { - $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('country_id')->orderBy('country'); + $query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->groupBy('country_id')->orderBy('country'); $timeframe = $get('starttime_period') ?? []; if ($timeframe['start'] || $timeframe['end']) { @@ -134,7 +140,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable }) ->placeholder('Country'), Select::make('group_cc') - ->visible(fn () => auth()->user()->provider_id == 2) + ->visible(fn () => Auth::user()->provider_id == 2) ->placeholder('Country') ->hiddenLabel() ->label('') @@ -142,7 +148,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->preload() ->live() ->options(function (Get $get) { - $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_cc'); + $query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->groupBy('group_cc'); $timeframe = $get('starttime_period') ?? []; @@ -184,11 +190,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->preload() ->options(function (Get $get) { if ($get('country_id')) { - $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('country_id', $get('country_id'))->groupBy('group_id'); + $query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('country_id', $get('country_id'))->groupBy('group_id'); } elseif ($get('group_cc')) { - $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('group_cc', $get('group_cc'))->groupBy('group_id'); + $query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('group_cc', $get('group_cc'))->groupBy('group_id'); } else { - $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->groupBy('group_id'); + $query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->groupBy('group_id'); } $timeframe = $get('starttime_period') ?? []; @@ -310,7 +316,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->requiresConfirmation() ->action(function (Component $livewire) { - Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->delete(); + Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->delete(); $this->search_values = []; $this->tableSearch = ''; // Clears the main search bar @@ -321,16 +327,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable Notification::make() ->success() ->title('Events deleted') - ->body('All events for '.Sport::query()->where('id', auth()->user()->sport_id)->value('name').' has been deleted successfully. It will take up to 5 minutes to reload'), + ->body('All events for '.Sport::query()->where('id', Auth::user()->sport_id)->value('name').' has been deleted successfully. It will take up to 5 minutes to reload'), ), ]); } - public function toggle() - { - $this->elements_swopped = ! $this->elements_swopped; - } - #[On('search_right')] public function searchRight($string) { @@ -381,6 +382,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable public function render() { + return view('livewire.mapper-right'); } } diff --git a/resources/views/filament/pages/event-mapper.blade.php b/resources/views/filament/pages/event-mapper.blade.php index 688a90c2..17f71995 100644 --- a/resources/views/filament/pages/event-mapper.blade.php +++ b/resources/views/filament/pages/event-mapper.blade.php @@ -1,5 +1,5 @@ -
+
@switch(auth()->user()->provider_id) @case(5) diff --git a/resources/views/livewire/confirm-mapping.blade.php b/resources/views/livewire/confirm-mapping.blade.php index b85dfd4b..66f6a0a6 100644 --- a/resources/views/livewire/confirm-mapping.blade.php +++ b/resources/views/livewire/confirm-mapping.blade.php @@ -49,18 +49,21 @@
{{ $event->home->name }}
+ {{-- @click="swop()" --}}
-
- -
- -
-
- -
-
+
+ + +
+ +
+
+ +
+
+