proclamatore = $proclamatore; } public function render() { $assegnazioni = Assegnazione::where('proclamatore_id', $this->proclamatore->id) ->with(['territorio', 'annoTeocratico', 'campagna']) ->orderByDesc('assigned_at') ->get() ->groupBy(fn($a) => $a->annoTeocratico->label); $stats = [ 'totale_assegnazioni' => Assegnazione::where('proclamatore_id', $this->proclamatore->id)->count(), 'attualmente_assegnati' => Assegnazione::where('proclamatore_id', $this->proclamatore->id)->aperte()->count(), 'media_giorni' => round( Assegnazione::where('proclamatore_id', $this->proclamatore->id) ->chiuse() ->get() ->avg(fn($a) => $a->giorni) ?? 0 ), ]; return view('livewire.proclamatori.proclamatore-show', [ 'assegnazioniPerAnno' => $assegnazioni, 'stats' => $stats, ]); } }