93 lines
3.8 KiB
PHP
93 lines
3.8 KiB
PHP
@extends('layouts.shop')
|
|
|
|
@php
|
|
$searchQuery = trim((string) request('q', ''));
|
|
$hasCatalogQuery = $searchQuery !== '' || request()->filled('category') || request()->filled('page');
|
|
$catalogCategoryList = collect($categories ?? [])
|
|
->values()
|
|
->map(fn ($category, $index) => [
|
|
'@type' => 'ListItem',
|
|
'position' => $index + 1,
|
|
'url' => route('catalog.category', $category),
|
|
'name' => $category->name,
|
|
])
|
|
->all();
|
|
$catalogSchema = [
|
|
'@context' => 'https://schema.org',
|
|
'@type' => 'CollectionPage',
|
|
'name' => 'Каталог товаров',
|
|
'url' => route('catalog.index'),
|
|
'description' => 'Каталог компьютерных комплектующих и техники.',
|
|
'mainEntity' => [
|
|
'@type' => 'ItemList',
|
|
'numberOfItems' => count($catalogCategoryList),
|
|
'itemListElement' => $catalogCategoryList,
|
|
],
|
|
];
|
|
@endphp
|
|
@section('meta_title', $searchQuery !== '' ? "Поиск: {$searchQuery}" : 'Каталог товаров')
|
|
@section(
|
|
'meta_description',
|
|
$searchQuery !== ''
|
|
? "Результаты поиска по запросу «{$searchQuery}». Подберите нужные комплектующие по наименованию."
|
|
: 'Каталог компьютерных комплектующих: процессоры, материнские платы, видеокарты, память, накопители и ноутбуки.'
|
|
)
|
|
@section('meta_keywords', 'каталог комплектующих, поиск товаров, процессоры, материнские платы, видеокарты')
|
|
@section('meta_canonical', route('catalog.index'))
|
|
@section('meta_robots', $hasCatalogQuery ? 'noindex,follow' : 'index,follow')
|
|
|
|
@push('structured_data')
|
|
<script type="application/ld+json">
|
|
@json($catalogSchema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
|
|
</script>
|
|
@endpush
|
|
|
|
@section('content')
|
|
@include('partials.breadcrumbs', [
|
|
'items' => [
|
|
['label' => 'Главная', 'url' => route('home')],
|
|
['label' => 'Каталог', 'url' => null],
|
|
],
|
|
])
|
|
|
|
<section class="pc-section">
|
|
<div class="pc-section-title">
|
|
<h2>Категории товаров</h2>
|
|
</div>
|
|
|
|
<div class="pc-grid pc-grid-4 pc-category-grid">
|
|
@forelse ($categories as $category)
|
|
<a class="pc-card pc-category-card pc-category-link" href="{{ route('catalog.category', $category) }}">
|
|
<div class="pc-category-image" role="img" aria-label="{{ $category->name }}"></div>
|
|
<h3 class="pc-category-title">{{ $category->name }}</h3>
|
|
</a>
|
|
@empty
|
|
<div class="pc-card">Категории пока не добавлены.</div>
|
|
@endforelse
|
|
</div>
|
|
</section>
|
|
|
|
@if (request()->filled('q'))
|
|
<section class="pc-section">
|
|
<div class="pc-category-toolbar">
|
|
<div class="pc-section-title">
|
|
<h2>Результаты по запросу: "{{ request('q') }}"</h2>
|
|
</div>
|
|
<p class="pc-muted">Найдено: <strong>{{ $products->total() }}</strong></p>
|
|
</div>
|
|
|
|
<div class="pc-products-grid">
|
|
@forelse ($products as $product)
|
|
@include('partials.product-card', ['product' => $product])
|
|
@empty
|
|
<div class="pc-card">По вашему запросу ничего не найдено.</div>
|
|
@endforelse
|
|
</div>
|
|
|
|
<div class="pc-pagination">
|
|
{{ $products->links('partials.pagination') }}
|
|
</div>
|
|
</section>
|
|
@endif
|
|
@endsection
|