From 07a726f1929da0611e0c790cb81b7d2810862001 Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 22 Feb 2026 16:17:49 +0100 Subject: [PATCH] mapper wip --- app/Livewire/MapperLeft.php | 6 ++++++ app/Livewire/MapperRight.php | 30 ++++++++++++++++++++++++++++++ app/Models/Mapper.php | 5 +++++ 3 files changed, 41 insertions(+) diff --git a/app/Livewire/MapperLeft.php b/app/Livewire/MapperLeft.php index 1c1f00ce..fa932f48 100644 --- a/app/Livewire/MapperLeft.php +++ b/app/Livewire/MapperLeft.php @@ -69,6 +69,12 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable ->query(LoadEvents::load($this->search_values)) ->striped() ->columns([ + IconColumn::make('sport.icon') + ->label('') + ->icon(fn ($record) => $record->sport->icon) + ->color(fn ($record) => $record->sport->color) + ->tooltip(fn ($record) => $record->id) + ->visibleFrom('lg'), IconColumn::make('country.icon')->icon(fn (string $state): string => $state)->label(''), TextColumn::make('competition_group.name')->label('Group') ->wrap() diff --git a/app/Livewire/MapperRight.php b/app/Livewire/MapperRight.php index 92b1825c..b7db38a7 100644 --- a/app/Livewire/MapperRight.php +++ b/app/Livewire/MapperRight.php @@ -9,11 +9,13 @@ use App\Livewire\Mapper\StoreMapped; use App\Models\Country; use App\Models\Event; use App\Models\Mapper; +use App\Models\Sport; use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker; use Filament\Actions\Action; use Filament\Actions\Concerns\InteractsWithActions; use Filament\Actions\Contracts\HasActions; use Filament\Forms\Components\Select; +use Filament\Notifications\Notification; use Filament\Schemas\Components\FusedGroup; use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Concerns\InteractsWithSchemas; @@ -83,6 +85,12 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable } }), IconColumn::make('group_cc')->icon(fn (string $state): string => 'flag-country-'.$state)->label(''), + IconColumn::make('sport.icon') + ->label('') + ->icon(fn ($record) => $record->sport->icon) + ->color(fn ($record) => $record->sport->color) + ->tooltip(fn ($record) => $record->id) + ->visibleFrom('lg'), ])->searchable(['home', 'away']) ->filters([ Filter::make('events') @@ -274,6 +282,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->toolbarActions([ Action::make('refresh_right') ->hiddenLabel() + ->tooltip('Reload') ->icon('phosphor-arrows-counter-clockwise') ->size(Size::Small) ->action(function (Component $livewire) { @@ -282,6 +291,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable Action::make('reload_right') ->hiddenLabel() ->icon('phosphor-x') + ->tooltip('Clear Filter and Reload') ->size(Size::Small) ->action(function (Component $livewire) { $this->search_values = []; @@ -290,6 +300,26 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable $livewire->resetTableFiltersForm(); // Clears all filters $this->dispatch('refreshMapperRight'); }), + Action::make('empty_mapper') + ->hiddenLabel() + ->color('danger') + ->icon('phosphor-trash') + ->tooltip('Empty Database and Reload from Provider') + ->size(Size::Small) + ->requiresConfirmation() + ->action(function (Component $livewire) { + 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 + $livewire->fill(['tableSearch' => '']); + $livewire->resetTableFiltersForm(); // Clears all filters + $this->dispatch('refreshMapperRight'); + })->successNotification( + 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'), + ), ]); } diff --git a/app/Models/Mapper.php b/app/Models/Mapper.php index 557a9fa6..27b53540 100644 --- a/app/Models/Mapper.php +++ b/app/Models/Mapper.php @@ -36,4 +36,9 @@ class Mapper extends Model { return $this->belongsTo(Provider::class); } + + public function sport() + { + return $this->belongsTo(Sport::class)->where('is_active', 1); + } }