@php $state = $state ?? []; $options = $options ?? []; $selectedYear = $state['year'] ?? ''; $selectedMonth = $state['month'] ?? ''; $selectedSector = $state['sector_id'] ?? ''; $selectedBusiness = $state['business_id'] ?? ''; $years = $options['years'] ?? []; $months = $options['months'] ?? []; $sectors = $options['sectors'] ?? []; $businesses = $options['businesses'] ?? []; $hasActiveFilters = !empty($selectedYear) || !empty($selectedMonth) || !empty($selectedSector) || !empty($selectedBusiness); $buildUrl = function (array $changes = []) { $query = request()->query(); unset($query['page']); foreach ($changes as $key => $value) { if ($value === null || $value === '') { unset($query[$key]); } else { $query[$key] = $value; } } return request()->url() . (count($query) ? ('?' . http_build_query($query)) : ''); }; @endphp
Filters
@if($selectedYear)Year: {{ $selectedYear }}@endif @if($selectedMonth)Month: {{ $months[$selectedMonth] ?? $selectedMonth }}@endif @if($selectedSector)Sector: {{ $sectors[$selectedSector] ?? $selectedSector }}@endif @if($selectedBusiness)Business: {{ $businesses[$selectedBusiness] ?? $selectedBusiness }}@endif @if($selectedYear || $selectedMonth || $selectedSector || $selectedBusiness) Clear all @endif
All @foreach($years as $value => $label) {{ $label }} @endforeach
All @foreach($months as $value => $label) {{ $label }} @endforeach
All @foreach($sectors as $id => $name) {{ $name }} @endforeach
@if($selectedSector || $selectedBusiness)
All @foreach($businesses as $id => $name) {{ $name }} @endforeach
@else Select sector first to load businesses @endif