Primo commit
This commit is contained in:
42
app/Livewire/Proclamatori/ProclamatoreShow.php
Normal file
42
app/Livewire/Proclamatori/ProclamatoreShow.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Proclamatori;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\Proclamatore;
|
||||
use App\Models\Assegnazione;
|
||||
|
||||
class ProclamatoreShow extends Component
|
||||
{
|
||||
public Proclamatore $proclamatore;
|
||||
|
||||
public function mount(Proclamatore $proclamatore)
|
||||
{
|
||||
$this->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user