@php /** @var \Illuminate\Support\Collection $stabili */ /** @var \App\Models\Stabile|null $stabileAttivo */ $activeId = $stabileAttivo?->id; $stabileHasRiscaldamento = static function (?\App\Models\Stabile $stabile): bool { if (! $stabile) { return false; } if ((bool) ($stabile->riscaldamento_centralizzato ?? false)) { return true; } $rateRiscaldamento = $stabile->rate_riscaldamento_mesi ?? []; if (is_string($rateRiscaldamento)) { $rateRiscaldamento = json_decode($rateRiscaldamento, true); } if (is_array($rateRiscaldamento) && $rateRiscaldamento !== []) { return true; } $config = $stabile->configurazione_avanzata ?? []; if (is_string($config)) { $config = json_decode($config, true); } if (is_array($config) && array_key_exists('mostra_riscaldamento', $config) && $config['mostra_riscaldamento']) { return true; } return \Illuminate\Support\Facades\DB::table('gestioni_contabili') ->where('stabile_id', $stabile->id) ->where('tipo_gestione', 'riscaldamento') ->exists(); }; $stabileLabel = static function (?\App\Models\Stabile $stabile): string { if (! $stabile) { return ''; } $primary = trim((string) ($stabile->codice_operatore ?: $stabile->codice_stabile)); $mnemo = trim((string) ($stabile->cod_stabile ?? '')); if ($mnemo !== '' && $primary !== '' && $mnemo !== $primary) { return $mnemo . ' · ' . $primary; } return $primary !== '' ? $primary : ($mnemo !== '' ? $mnemo : ('#' . (string) $stabile->id)); }; @endphp
@if($stabileAttivo) @endif @if($stabili->count() > 1)
@csrf
@endif