From 51a195e657a38f9ac4e6f3859dcbabad352cce02 Mon Sep 17 00:00:00 2001 From: salam Date: Mon, 2 Feb 2026 09:02:39 +0100 Subject: [PATCH] wip --- .../Resources/Events/EventResource.php | 12 ------ .../Resources/Events/Pages/ListEvents.php | 20 +++++++++- .../Resources/Events/Tables/EventsTable.php | 30 +++++++++++++++ app/Livewire/BettypeToggle.php | 37 ++++++++----------- app/Providers/AppServiceProvider.php | 1 + .../views/livewire/bettype-toggle.blade.php | 6 ++- 6 files changed, 70 insertions(+), 36 deletions(-) diff --git a/app/Filament/Resources/Events/EventResource.php b/app/Filament/Resources/Events/EventResource.php index 24468473..98c457cd 100644 --- a/app/Filament/Resources/Events/EventResource.php +++ b/app/Filament/Resources/Events/EventResource.php @@ -65,18 +65,6 @@ class EventResource extends Resource ->where('sport_id', auth()->user()->sport_id) ->where('starttime', '>=', now()); - if (auth()->user()->filter_stars) { - $query->whereHas('event_user_star'); - } - - if (auth()->user()->filter_notes) { - $query->whereHas('event_user_note'); - } - - if (auth()->user()->filter_notification) { - $query->whereHas('event_user_notification'); - } - if (auth()->user()->all_only_none > 0) { switch (auth()->user()->all_only_none) { case 1: diff --git a/app/Filament/Resources/Events/Pages/ListEvents.php b/app/Filament/Resources/Events/Pages/ListEvents.php index d468daa0..ea8ca794 100644 --- a/app/Filament/Resources/Events/Pages/ListEvents.php +++ b/app/Filament/Resources/Events/Pages/ListEvents.php @@ -15,11 +15,14 @@ class ListEvents extends ListRecords protected $listeners = [ 'refreshBettypeMenu' => '$refresh', + 'filterClearFilter' => 'clearFilters', 'filterUpdateGreen' => 'updateTableFiltersGreen', 'filterUpdateYellow' => 'updateTableFiltersYellow', 'filterUpdateRed' => 'updateTableFiltersRed', 'filterUpdatePeriode' => 'updateTablePeriode', - 'filterClearFilter' => 'clearFilters', + 'filterStarFilter' => 'updateStar', + 'filterNoteFilter' => 'updateNote', + 'filterNotificationFilter' => 'updateNotification', ]; protected function getHeaderWidgets(): array @@ -34,6 +37,21 @@ class ListEvents extends ListRecords $this->removeTableFilters(); } + // public function updateStar(): void + // { + // $this->tableFilters['events']['filter_stars'] = auth()->user()->filter_stars; + // } + + // public function updateNote(): void + // { + // $this->tableFilters['events']['filter_notes'] = auth()->user()->filter_notes; + // } + + // public function updateNotification(): void + // { + // $this->tableFilters['events']['filter_notification'] = auth()->user()->filter_notification; + // } + public function updateTablePeriode(string $filter): void { $filter = json_decode($filter, true); diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 9bf2632a..67822602 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -182,6 +182,9 @@ class EventsTable Hidden::make('filter_alarm_green'), Hidden::make('filter_alarm_yellow'), Hidden::make('filter_alarm_red'), + Hidden::make('filter_stars'), + Hidden::make('filter_notes'), + Hidden::make('filter_notification'), Select::make(name: 'country_id') ->hidden(fn () => auth()->user()->sport_id == 5) ->placeholder('Country') @@ -378,6 +381,21 @@ class EventsTable $query->whereIn('id', $event_ids); } + )->when( + $data['filter_stars'], + function (Builder $query, $filter_stars) { + $query->whereHas('event_user_star'); + } + )->when( + $data['filter_notes'], + function (Builder $query, $filter_notes) { + $query->whereHas('event_user_note'); + } + )->when( + $data['filter_notification'], + function (Builder $query, $filter_notification) { + $query->whereHas('event_user_notification'); + } )->when( $data['favorit_threshold'], function (Builder $query, $favorit_threshold) { @@ -427,6 +445,18 @@ class EventsTable } } + if ($data['filter_stars'] ?? null) { + $indicators[] = Indicator::make('Filter Favorits')->removeField('filter_stars')->color('success'); + } + + if ($data['filter_notes'] ?? null) { + $indicators[] = Indicator::make('Filter Notes')->removeField('filter_notes')->color('success'); + } + + if ($data['filter_notification'] ?? null) { + $indicators[] = Indicator::make('Filter Notifications')->removeField('filter_notification')->color('success'); + } + if ($data['filter_alarm_green'] ?? null) { $title = OddsTable::where('name', $data['filter_alarm_green'])->value('title'); $indicators[] = Indicator::make('Alarms: '.$title)->removeField('filter_alarm_green')->color('success'); diff --git a/app/Livewire/BettypeToggle.php b/app/Livewire/BettypeToggle.php index 00ecf3fb..600f440e 100644 --- a/app/Livewire/BettypeToggle.php +++ b/app/Livewire/BettypeToggle.php @@ -43,33 +43,26 @@ class BettypeToggle extends Component public function toggleBettype($multiline_setting_id) { BettypeUser::where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]); - $this->dispatch('refreshBettypeMenu'); } - public function toggleStar() - { - User::where('id', auth()->user()->id)->update(['filter_stars' => DB::raw('!filter_stars')]); + // public function toggleStar() + // { + // User::where('id', auth()->user()->id)->update(['filter_stars' => DB::raw('!filter_stars')]); + // $this->dispatch('filterStarFilter'); + // } - $this->dispatch('filterClearFilter'); - $this->dispatch('refreshBettypeMenu'); - } + // public function toggleNote() + // { + // User::where('id', auth()->user()->id)->update(['filter_notes' => DB::raw('!filter_notes')]); + // $this->dispatch('filterNotificationFilter'); + // } - public function toggleNote() - { - User::where('id', auth()->user()->id)->update(['filter_notes' => DB::raw('!filter_notes')]); - - $this->dispatch('filterClearFilter'); - $this->dispatch('refreshBettypeMenu'); - } - - public function toggleNotification() - { - User::where('id', auth()->user()->id)->update(['filter_notification' => DB::raw('!filter_notification')]); - - $this->dispatch('filterClearFilter'); - $this->dispatch('refreshBettypeMenu'); - } + // public function toggleNotification() + // { + // User::where('id', auth()->user()->id)->update(['filter_notification' => DB::raw('!filter_notification')]); + // $this->dispatch('filterStarFilter'); + // } public function toggleShowPartner() { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2b94ad4f..30591f70 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -39,6 +39,7 @@ class AppServiceProvider extends ServiceProvider ListEvents::class, ] ); + // PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE, FilamentView::registerRenderHook( TablesRenderHook::TOOLBAR_SEARCH_AFTER, fn (): string => Blade::render('@livewire(\'bettype-toggle\')'), diff --git a/resources/views/livewire/bettype-toggle.blade.php b/resources/views/livewire/bettype-toggle.blade.php index d1d9b604..2c0e92b7 100644 --- a/resources/views/livewire/bettype-toggle.blade.php +++ b/resources/views/livewire/bettype-toggle.blade.php @@ -50,10 +50,14 @@ :icon="auth()->user()->is_multiline_direct ? 'phosphor-not-equals' : 'phosphor-equals'"> - + {{-- + --}} +