@extends('site.layouts.new.app') @php $latestDocumentItems = collect($latestDocuments ?? [])->take(2)->map(function ($item, $index) { $title = trim((string) ($item->document_type->name ?? 'Documento')); if (!empty($item->number) && $item->number !== '0') { $title .= ' ' . $item->number; if (!empty($item->date)) { try { $title .= '/' . $item->getYear($item->date); } catch (\Throwable $exception) { } } } return [ 'title' => $title, 'subtitle' => $item->owner->short_name ?? ($item->user->name ?? 'Responsável não informado'), 'date' => $item->date ?? '-', 'tone' => $index === 0 ? 'is-blue' : 'is-amber', 'href' => route('DocumentDetailsFront', ['id' => $item->id, 'documents' => 'true', 'front_layout' => 'new']), ]; }); $latestLawProjectItems = collect($latestLawProjects ?? [])->take(2)->map(function ($item, $index) { $title = trim((string) ($item->law_type->name ?? 'Projeto de Lei')); if (!empty($item->project_number) && $item->project_number !== '0') { $title .= ' ' . $item->project_number; if (!empty($item->law_date)) { try { $title .= '/' . $item->getYearLawPublish($item->law_date); } catch (\Throwable $exception) { } } } return [ 'title' => $title, 'subtitle' => $item->assemblyman->short_name ?? 'Responsável não informado', 'date' => $item->law_date ?? '-', 'tone' => $index === 0 ? 'is-blue' : 'is-amber', 'href' => route('LawsDetailsFront', ['id' => $item->id]) . '?projects=true&front_layout=new', ]; }); $latestItems = $latestDocumentItems ->concat($latestLawProjectItems) ->take(4) ->values(); $sessionItems = collect($upcomingMeetings ?? [])->take(3)->map(function ($item) { $formattedDate = '-'; if (!empty($item->date_start)) { try { $formattedDate = \Carbon\Carbon::createFromFormat('d/m/Y H:i', $item->date_start)->format('d/m/Y'); } catch (\Throwable $exception) { try { $formattedDate = \Carbon\Carbon::parse($item->date_start)->format('d/m/Y'); } catch (\Throwable $exception) { $formattedDate = (string) $item->date_start; } } } return [ 'title' => trim(($item->sessionType->name ?? 'Sessão') . ' ' . ($item->number ?? '-')), 'subtitle' => $item->sessionType->name ?? 'Sessão', 'date' => $formattedDate, 'tone' => 'is-blue', 'href' => route('site.propositions', ['id' => $item->id, 'front_layout' => 'new']), ]; })->values(); $documentTypeChartItems = collect($documentTypeChartItems ?? [])->values(); @endphp @section('site_content')
@include('site.components.stat-card', ['title' => 'Total de Documentos', 'subtitle' => 'Documentos', 'value' => number_format($documentsCount ?? 0, 0, ',', '.'), 'icon' => 'document']) @include('site.components.stat-card', ['title' => 'Total de sessões', 'subtitle' => 'Sessões', 'value' => number_format($meetingCount ?? 0, 0, ',', '.'), 'icon' => 'calendar']) @include('site.components.stat-card', ['title' => 'Total de Projetos', 'subtitle' => 'Projetos', 'value' => number_format($lawsCount ?? 0, 0, ',', '.'), 'icon' => 'edit']) @include('site.components.stat-card', ['title' => 'Total de Vereadores', 'subtitle' => 'vereadores', 'value' => number_format($assemblymanCount ?? 0, 0, ',', '.'), 'icon' => 'users'])
@component('site.components.panel', ['title' => 'Documentos mais publicados', 'bodyClass' => 'sl-panel__body--document-chart']) @if ($documentTypeChartItems->isNotEmpty()) @include('site.components.document-type-chart', [ 'items' => $documentTypeChartItems->all(), ]) @else

Nenhum documento encontrado para montar o ranking no momento.

@endif @endcomponent @component('site.components.panel', ['title' => 'Matérias recentes', 'actionLabel' => 'Ver todos', 'actionHref' => route('site.materials', ['front_layout' => 'new', 'tab' => 'documents'])])
@foreach ($latestItems as $item) @include('site.components.list-row', [ 'title' => $item['title'], 'subtitle' => $item['subtitle'], 'date' => $item['date'], 'tone' => $item['tone'], 'buttonLabel' => 'Ver detalhes', 'buttonHref' => $item['href'], 'buttonClass' => 'sl-inline-action--home', ]) @endforeach
@endcomponent
@component('site.components.panel', ['title' => 'Próxima Sessão', 'actionLabel' => 'Ver todos', 'actionHref' => route('site.meetings', ['front_layout' => 'new'])]) @if ($sessionItems->isNotEmpty())
@foreach ($sessionItems as $item) @include('site.components.list-row', [ 'title' => $item['title'], 'subtitle' => $item['subtitle'], 'date' => $item['date'], 'tone' => $item['tone'], 'buttonLabel' => 'Ver detalhes', 'buttonHref' => $item['href'], 'buttonClass' => 'sl-inline-action--home', ]) @endforeach
@else

Nenhuma sessão agendada no momento.

@endif @endcomponent
@endsection