{{ $list->name }}

@foreach($filterDefs as $field => $def) @php $opts = $filterOptions[$field] ?? []; $value = $selected[$field] ?? null; $isArray = is_array($value); $typedValues = request()->input('q', []); $typedValue = $typedValues[$field] ?? ''; @endphp
{{-- 1) Champ texte + autocomplétion en premier --}} @if(!empty($opts)) @foreach($opts as $val => $label) @endforeach @endif {{-- 2) UI principale du filtre (radio / checkbox / buttons / select) --}} @switch($def['ui']) @case('radio') @foreach($opts as $val => $label) @endforeach @break @case('checkbox') @foreach($opts as $val => $label) @endforeach @break @case('buttons') {{-- champ hidden pour garder la valeur courante de ce filtre --}}
@foreach($opts as $val => $label) @endforeach
@break @default {{-- select --}} @endswitch
@endforeach
@php // On garantit que les variables existent et sont des collections $catalogueRows = $catalogueRows ?? collect(); $horsStandardRows = $horsStandardRows ?? collect(); $horsCatalogueRows = $horsCatalogueRows ?? collect(); $defautRows = $defautRows ?? collect(); $groups = [ 'Articles catalogue' => $catalogueRows, 'Articles hors standard' => $horsStandardRows, 'Articles hors catalogue' => $horsCatalogueRows, 'Articles avec défauts' => $defautRows, ]; $hasAny = $catalogueRows->isNotEmpty() || $horsStandardRows->isNotEmpty() || $horsCatalogueRows->isNotEmpty() || $defautRows->isNotEmpty(); @endphp @if (! $hasAny)

Aucune ligne.

@else @foreach($groups as $title => $rows) @if ($rows->isNotEmpty())

{{ $title }}

@foreach($columns as $c) @endforeach @foreach($rows as $r) @foreach($columns as $c) @endforeach @endforeach
{{ \Illuminate\Support\Str::headline(str_replace('_',' ',$c)) }}
@php $isArticleCol = (strtolower($c) === 'article'); @endphp @if($isArticleCol && ($list->allow_details ?? false)) @php // on essaie de récupérer le choix sur la ligne si la colonne existe $choixValue = null; try { $choixValue = $r->choix ?? null; } catch (\Throwable $e) { $choixValue = null; } $detailUrl = route('stocks.article', [ 'slug' => $list->slug, 'article' => $r->{$c}, 'choix' => $choixValue, // 👈 passera null si non défini ]); @endphp {{ $r->{$c} }} @else {{ $r->{$c} }} @endif
@endif @endforeach @endif