62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages\Supporto;
|
|
|
|
use App\Models\Ticket;
|
|
use App\Models\User;
|
|
use App\Support\StabileContext;
|
|
use BackedEnum;
|
|
use Filament\Pages\Page;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use UnitEnum;
|
|
|
|
class Avvisi extends Page
|
|
{
|
|
protected static ?string $navigationLabel = 'Avvisi';
|
|
|
|
protected static ?string $title = 'Avvisi';
|
|
|
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-bell-alert';
|
|
|
|
protected static UnitEnum|string|null $navigationGroup = 'Supporto';
|
|
|
|
protected static ?int $navigationSort = 20;
|
|
|
|
protected static ?string $slug = 'supporto/avvisi';
|
|
|
|
protected string $view = 'filament.pages.supporto.avvisi';
|
|
|
|
/** @var \Illuminate\Support\Collection<int, Ticket> */
|
|
public $tickets;
|
|
|
|
public static function canAccess(): bool
|
|
{
|
|
$user = Auth::user();
|
|
return $user instanceof User
|
|
&& $user->hasAnyRole(['super-admin', 'admin', 'amministratore', 'collaboratore']);
|
|
}
|
|
|
|
public function mount(): void
|
|
{
|
|
$user = Auth::user();
|
|
if (! $user instanceof User) {
|
|
$this->tickets = collect();
|
|
return;
|
|
}
|
|
|
|
$stabileId = StabileContext::resolveActiveStabileId($user);
|
|
if (! $stabileId) {
|
|
$this->tickets = collect();
|
|
return;
|
|
}
|
|
|
|
$this->tickets = Ticket::query()
|
|
->where('stabile_id', $stabileId)
|
|
->whereIn('stato', ['Aperto', 'Preso in Carico', 'In Lavorazione'])
|
|
->where('priorita', '!=', 'Urgente')
|
|
->latest('data_apertura')
|
|
->limit(20)
|
|
->get();
|
|
}
|
|
}
|