{{-- resources/views/wiki/partials/filter_list.blade.php --}} @php $filters = $filters ?? [ 'q' => request('q', ''), 'rarity' => request('rarity', ''), 'faction' => request('faction', ''), 'min_level' => request('min_level', ''), 'max_level' => request('max_level', ''), 'item_type' => request('item_type', ''), 'sort' => request('sort', 'id_asc'), ]; $items = $items ?? []; $isPaginator = $items instanceof \Illuminate\Pagination\LengthAwarePaginator || $items instanceof \Illuminate\Contracts\Pagination\Paginator || $items instanceof \Illuminate\Contracts\Pagination\LengthAwarePaginator; $itemCount = is_array($items) ? count($items) : (is_object($items) && method_exists($items, 'count') ? $items->count() : 0); $rarities = $rarities ?? []; $itemTypes = $itemTypes ?? []; $factions = $factions ?? []; // Support enums or plain strings $val = fn($x) => is_object($x) && isset($x->value) ? (string) $x->value : (string) $x; $label = function ($x) { if (is_object($x)) { if (method_exists($x, 'label')) return (string) $x->label(); if (isset($x->value)) return ucfirst((string) $x->value); } $s = (string) $x; return $s === '' ? '' : ucfirst($s); }; // Build option maps value => label for custom dropdowns $rarOpts = []; foreach ($rarities as $r) { $v = $val($r); if ($v === '') continue; $rarOpts[$v] = $label($r); } $facOpts = []; foreach ($factions as $f) { $v = $val($f); if ($v === '') continue; // faction labels are already Title Case typically $facOpts[$v] = is_object($f) && method_exists($f, 'label') ? (string) $f->label() : (string) $v; } $sortOpts = [ 'id_asc' => 'ID (low→high)', 'id_desc' => 'ID (high→low)', 'name_asc' => 'Name (A→Z)', 'name_desc' => 'Name (Z→A)', 'level_asc' => 'Level (low→high)', 'level_desc' => 'Level (high→low)', 'rarity_asc' => 'Rarity (low→high)', 'rarity_desc' => 'Rarity (high→low)', ]; $rarSelected = (string) ($filters['rarity'] ?? ''); $facSelected = (string) ($filters['faction'] ?? ''); $typeSelected = (string) ($filters['item_type'] ?? ''); $sortSelected = (string) ($filters['sort'] ?? 'id_asc'); @endphp
Filters
{{-- Search --}}
{{-- Levels --}}
{{-- Item type --}} @if(!empty($itemTypes))
@foreach($itemTypes as $type) @endforeach
@endif {{-- Custom Dropdowns: Rarity + Faction --}}
{{-- Rarity dropdown --}}
@foreach($rarOpts as $v => $lbl) @endforeach
{{-- Faction dropdown --}}
@foreach($facOpts as $v => $lbl) @endforeach
{{-- Custom Dropdown: Sort + Submit --}}
@foreach($sortOpts as $v => $lbl) @endforeach
{{-- Results --}} @if($itemCount === 0)

No items found.

@else
Name
Level
Rarity
Faction
@foreach($items as $it) @php $id = (string) ($it['id'] ?? ''); $href = url('/wiki/' . $game . '/items/' . $category . '/' . $id); $name = trim((string) ($it['name'] ?? '')); if ($name === '') { $name = $id; } $icon = $it['icon'] ?? null; $rar = strtolower((string) ($it['rarity'] ?? '')); $fac = strtolower((string) ($it['faction'] ?? '')); $rClass = $rar ? 'wk-q-' . $rar : ''; $fClass = $fac ? 'wk-f-' . $fac : ''; $lvl = (int) ($it['level_requirement'] ?? 0); $isStack = filter_var($it['stackable'] ?? false, FILTER_VALIDATE_BOOLEAN); @endphp
@if($icon){{ $name }}@endif {{ $name }}
{{ $lvl ?: '-' }}
{{ $rar ? ucfirst($rar) : '-' }}
{{ $it['faction'] ?? '-' }}
@endforeach
@if($isPaginator && method_exists($items, 'lastPage') && $items->lastPage() > 1) @endif @endif