fix swop for mapper

This commit is contained in:
salam committed 2026-04-17 09:34:49 +02:00
1 parent dce543604f
commit 60b524012d
5 files changed
+44 -37

No files matched your search

+18 -16
View File
@@ -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');
}
}