@extends('layouts.shop') @php $translatedCategoryName = __($category->name); $translatedCategoryDescription = $category->description ? __($category->description) : __('Категория товаров :category', ['category' => $translatedCategoryName]); $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' => $translatedCategoryName, 'url' => route('catalog.category', $category), 'description' => $translatedCategoryDescription, 'mainEntity' => [ '@type' => 'ItemList', 'numberOfItems' => $products->total(), 'itemListElement' => $categoryItemList, ], ]; @endphp @section('meta_title', $translatedCategoryName) @section('meta_description', __('Товары категории :category. Фильтры и сортировка для быстрого подбора.', ['category' => $translatedCategoryName])) @section('meta_keywords', __(':category, комплектующие, купить, фильтры товаров', ['category' => $translatedCategoryName])) @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' => $translatedCategoryName, 'url' => null], ], ])

{{ $translatedCategoryName }}

@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(__('Цена: :from - :to', ['from' => $priceFromLabel, 'to' => $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(__(':label: :from - :to', [ 'label' => __($filter['label'] ?? $rangeKey), 'from' => $fromLabel, 'to' => $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