fix swop for mapper
This commit is contained in:
1 parent
dce543604f
commit
60b524012d
5 files changed
+44
-37
No files matched your search
@@ -18,7 +18,7 @@ class StoreMapped
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
// dd($mapper);
|
||||
dd($mapper, $arguments, $swopped);
|
||||
|
||||
/*
|
||||
EVENT
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="absolute top-25 left-30 ">
|
||||
<div class="inline-block absolute top-22 ">
|
||||
@switch(auth()->user()->provider_id)
|
||||
@case(5)
|
||||
<x-bkm-logifuture-nigeria class="h-5" />
|
||||
|
||||
@@ -49,18 +49,21 @@
|
||||
</div>
|
||||
|
||||
<div class="pt-2 font-bold text-right">{{ $event->home->name }}</div>
|
||||
{{-- @click="swop()" --}}
|
||||
|
||||
<div class="row-span-2 text-center py-auto">
|
||||
<div x-data="{ elements_swopped: false, toggle() { this.elements_swopped = !this.elements_swopped } }" x-init="elements_swopped = true">
|
||||
<x-filament::button color="gray" outlined @click="toggle()" wire:click="toggle()"
|
||||
onkeydown="return event.key != 'Enter';">
|
||||
<div x-show="elements_swopped">
|
||||
<x-icon-paralell class="h-14 w-14 mx-auto" />
|
||||
</div>
|
||||
<div x-show="!elements_swopped">
|
||||
<x-icon-crossed class="h-14 w-14 mx-auto" />
|
||||
</div>
|
||||
</x-filament::button>
|
||||
<div x-data="{ elements_swopped: false, toggle_icon() { this.elements_swopped = !this.elements_swopped } }" x-init="elements_swopped = true">
|
||||
<span wire:click="toggle_icon()">
|
||||
<x-filament::button color="gray" outlined wire:click="swop_elements"
|
||||
onkeydown="return event.key != 'Enter';">
|
||||
<div x-show="elements_swopped">
|
||||
<x-icon-paralell class="h-14 w-14 mx-auto" />
|
||||
</div>
|
||||
<div x-show="!elements_swopped">
|
||||
<x-icon-crossed class="h-14 w-14 mx-auto" />
|
||||
</div>
|
||||
</x-filament::button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user