62 lines
1.6 KiB
PHP
Executable File
62 lines
1.6 KiB
PHP
Executable File
<?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 Urgenze extends Page
|
|
{
|
|
protected static ?string $navigationLabel = 'Urgenze';
|
|
|
|
protected static ?string $title = 'Urgenze';
|
|
|
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-exclamation-triangle';
|
|
|
|
protected static UnitEnum|string|null $navigationGroup = 'Supporto';
|
|
|
|
protected static ?int $navigationSort = 10;
|
|
|
|
protected static ?string $slug = 'supporto/urgenze';
|
|
|
|
protected string $view = 'filament.pages.supporto.urgenze';
|
|
|
|
/** @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();
|
|
}
|
|
}
|