@extends('layouts.shop') @php $hasSeoFilters = request()->filled('q') || request()->filled('sort') || request()->filled('page') || request()->filled('price_from') || request()->filled('price_to') || collect((array) request('filters', [])) ->contains(fn ($value) => is_scalar($value) && trim((string) $value) !== '') || collect(request()->query()) ->keys() ->contains(fn ($key) => is_string($key) && (str_ends_with($key, '_from') || str_ends_with($key, '_to'))); $categoryItemList = collect($products->items()) ->values() ->map(fn ($product, $index) => [ '@type' => 'ListItem', 'position' => $index + 1, 'url' => route('products.show', $product), 'name' => $product->name, ]) ->all(); $categorySchema = [ '@context' => 'https://schema.org', '@type' => 'CollectionPage', 'name' => $category->name, 'url' => route('catalog.category', $category), 'description' => $category->description ?: 'Категория товаров ' . $category->name, 'mainEntity' => [ '@type' => 'ItemList', 'numberOfItems' => $products->total(), 'itemListElement' => $categoryItemList, ], ]; @endphp @section('meta_title', $category->name) @section('meta_description', ($category->description ?: 'Товары категории ' . $category->name . '.') . ' Фильтры и сортировка для быстрого подбора.') @section('meta_keywords', $category->name . ', комплектующие, купить, фильтры товаров') @section('meta_canonical', route('catalog.category', $category)) @section('meta_robots', $hasSeoFilters ? 'noindex,follow' : 'index,follow') @push('structured_data') @endpush @section('content') @include('partials.breadcrumbs', [ 'items' => [ ['label' => 'Главная', 'url' => route('home')], ['label' => 'Каталог', 'url' => route('catalog.index')], ['label' => $category->name, 'url' => null], ], ])

{{ $category->name }}

@php $activeFilters = collect((array) ($appliedFilters ?? [])) ->filter(fn ($value) => is_scalar($value) && trim((string) $value) !== '') ->values(); if (request()->filled('price_from') || request()->filled('price_to')) { $priceFromLabel = trim((string) request('price_from', '')); $priceToLabel = trim((string) request('price_to', '')); $activeFilters->push("Цена: {$priceFromLabel} - {$priceToLabel}"); } foreach ((array) ($filters ?? []) as $filter) { if ((string) ($filter['filter'] ?? 'select') !== 'range') { continue; } $rangeKey = (string) ($filter['key'] ?? ''); if ($rangeKey === '') { continue; } $fromParam = $rangeKey . '_from'; $toParam = $rangeKey . '_to'; if (!request()->filled($fromParam) && !request()->filled($toParam)) { continue; } $fromLabel = trim((string) request($fromParam, '')); $toLabel = trim((string) request($toParam, '')); $activeFilters->push(($filter['label'] ?? $rangeKey) . ": {$fromLabel} - {$toLabel}"); } @endphp

Найдено товаров: {{ $products->total() }}

@foreach ((array) ($appliedFilters ?? []) as $key => $value) @if (is_scalar($value) && trim((string) $value) !== '') @endif @endforeach @if (request()->filled('price_from')) @endif @if (request()->filled('price_to')) @endif @foreach ((array) ($filters ?? []) as $filter) @php $rangeKey = (string) ($filter['key'] ?? ''); @endphp @continue($rangeKey === '' || (string) ($filter['filter'] ?? 'select') !== 'range') @if (request()->filled($rangeKey . '_from')) @endif @if (request()->filled($rangeKey . '_to')) @endif @endforeach @if (request()->filled('q')) @endif
@if ($activeFilters->isNotEmpty())
@foreach ($activeFilters as $key => $value) {{ $value }} @endforeach
@endif
@forelse ($products as $product) @include('partials.product-card', ['product' => $product]) @empty
Пока нет товаров в этой категории.
@endforelse
{{ $products->links('partials.pagination') }}
@endsection