diff --git a/app/Filament/Pages/Condomini/AssembleeHub.php b/app/Filament/Pages/Condomini/AssembleeHub.php index 1a5b082..db06a11 100644 --- a/app/Filament/Pages/Condomini/AssembleeHub.php +++ b/app/Filament/Pages/Condomini/AssembleeHub.php @@ -1,5 +1,4 @@ hasAnyRole(['super-admin', 'admin', 'amministratore', 'collaboratore']); + && $user->hasAnyRole(['super-admin', 'admin', 'amministratore', 'collaboratore']); } public function mount(): void @@ -68,42 +69,59 @@ protected function getHeaderActions(): array public function getStatsProperty(): array { $stabileId = (int) ($this->stabileAttivo?->id ?? 0); - if ($stabileId <= 0) { + if ($stabileId <= 0 || ! $this->canQueryAssemblee()) { return ['totale' => 0, 'convocate' => 0, 'in_calendario' => 0, 'con_verbale' => 0]; } - $query = Assemblea::query()->where('stabile_id', $stabileId); + try { + $query = Assemblea::query()->where('stabile_id', $stabileId); - return [ - 'totale' => (clone $query)->count(), - 'convocate' => (clone $query)->where('stato', 'convocata')->count(), - 'in_calendario'=> (clone $query) - ->where(function ($builder): void { - $today = now(); + return [ + 'totale' => (clone $query)->count(), + 'convocate' => (clone $query)->where('stato', 'convocata')->count(), + 'in_calendario' => (clone $query) + ->where(function ($builder): void { + $today = now(); - $builder->whereDate('data_prima_convocazione', '>=', $today->toDateString()) - ->orWhereDate('data_seconda_convocazione', '>=', $today->toDateString()); - }) - ->count(), - 'con_verbale' => (clone $query)->whereHas('verbale')->count(), - ]; + $builder->whereDate('data_prima_convocazione', '>=', $today->toDateString()) + ->orWhereDate('data_seconda_convocazione', '>=', $today->toDateString()); + }) + ->count(), + 'con_verbale' => (clone $query)->whereHas('verbale')->count(), + ]; + } catch (QueryException) { + return ['totale' => 0, 'convocate' => 0, 'in_calendario' => 0, 'con_verbale' => 0]; + } } public function getAssembleeRowsProperty(): Collection { $stabileId = (int) ($this->stabileAttivo?->id ?? 0); - if ($stabileId <= 0) { + if ($stabileId <= 0 || ! $this->canQueryAssemblee()) { return collect(); } - return Assemblea::query() - ->with(['verbale:id,assemblea_id']) - ->withCount(['ordineGiorno', 'convocazioni', 'presenze', 'documenti']) - ->where('stabile_id', $stabileId) - ->orderByDesc('data_seconda_convocazione') - ->orderByDesc('data_prima_convocazione') - ->orderByDesc('id') - ->limit(16) - ->get(); + try { + return Assemblea::query() + ->with(['verbale:id,assemblea_id']) + ->withCount(['ordineGiorno', 'convocazioni', 'presenze', 'documenti']) + ->where('stabile_id', $stabileId) + ->orderByDesc('data_seconda_convocazione') + ->orderByDesc('data_prima_convocazione') + ->orderByDesc('id') + ->limit(16) + ->get(); + } catch (QueryException) { + return collect(); + } } -} \ No newline at end of file + + private function canQueryAssemblee(): bool + { + try { + return Schema::hasTable((new Assemblea())->getTable()); + } catch (QueryException) { + return false; + } + } +} diff --git a/app/Providers/Filament/AdminFilamentPanelProvider.php b/app/Providers/Filament/AdminFilamentPanelProvider.php index 24087de..80cd773 100644 --- a/app/Providers/Filament/AdminFilamentPanelProvider.php +++ b/app/Providers/Filament/AdminFilamentPanelProvider.php @@ -102,8 +102,8 @@ public function panel(Panel $panel): Panel return $user instanceof User && $user->hasRole('fornitore'); }), ]) - ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') - ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') + ->discoverResources(in: app_path('Filament/Resources'), for : 'App\\Filament\\Resources') + ->discoverPages(in: app_path('Filament/Pages'), for : 'App\\Filament\\Pages') ->pages([ Dashboard::class, SupportoDashboard::class, @@ -111,7 +111,7 @@ public function panel(Panel $panel): Panel PrimaNotaModifica::class, ContoMastrino::class, ]) - ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') + ->discoverWidgets(in: app_path('Filament/Widgets'), for : 'App\\Filament\\Widgets') ->widgets([ AccountWidget::class, TicketMobileOverview::class, diff --git a/public/build/manifest.json b/public/build/manifest.json index 8f5b472..426a036 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -5,7 +5,7 @@ "isEntry": true }, "resources/css/filament/admin/theme.css": { - "file": "assets/theme-CDFysGCE.css", + "file": "assets/theme-Cs5qngWh.css", "src": "resources/css/filament/admin/theme.css", "isEntry": true }, diff --git a/resources/css/filament/admin/theme.css b/resources/css/filament/admin/theme.css index 0ca6322..6f8ebdf 100644 --- a/resources/css/filament/admin/theme.css +++ b/resources/css/filament/admin/theme.css @@ -23,20 +23,6 @@ .fi-main-ctn>main { overflow: visible !important; } -.fi-sidebar { - position: static !important; - top: auto !important; - align-self: stretch !important; - height: auto !important; - overflow: visible !important; -} - -.fi-sidebar-header { - position: static !important; - top: auto !important; - z-index: 20 !important; -} - .fi-main { flex: 1 1 auto; min-height: 0;