This commit is contained in:
112
resources/views/shop/search.blade.php
Normal file
112
resources/views/shop/search.blade.php
Normal file
@@ -0,0 +1,112 @@
|
||||
@extends('layouts.shop')
|
||||
|
||||
@php
|
||||
$searchItemList = collect($products->items())
|
||||
->values()
|
||||
->map(fn ($product, $index) => [
|
||||
'@type' => 'ListItem',
|
||||
'position' => $index + 1,
|
||||
'url' => route('products.show', $product),
|
||||
'name' => $product->name,
|
||||
])
|
||||
->all();
|
||||
$searchSchema = $searchQuery !== ''
|
||||
? [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'SearchResultsPage',
|
||||
'name' => "Результаты поиска: {$searchQuery}",
|
||||
'url' => route('search.index', ['q' => $searchQuery]),
|
||||
'mainEntity' => [
|
||||
'@type' => 'ItemList',
|
||||
'numberOfItems' => $products->total(),
|
||||
'itemListElement' => $searchItemList,
|
||||
],
|
||||
]
|
||||
: null;
|
||||
@endphp
|
||||
|
||||
@section('meta_title', $searchQuery !== '' ? "Поиск: {$searchQuery}" : 'Поиск товаров')
|
||||
@section(
|
||||
'meta_description',
|
||||
$searchQuery !== ''
|
||||
? "Найденные товары по запросу «{$searchQuery}». Выберите подходящий товар и откройте подробную карточку."
|
||||
: 'Поиск товаров по наименованию: процессоры, видеокарты, материнские платы, ноутбуки и периферия.'
|
||||
)
|
||||
@section('meta_keywords', 'поиск товаров, результаты поиска, комплектующие пк, ноутбуки')
|
||||
@section('meta_canonical', route('search.index'))
|
||||
@section('meta_robots', 'noindex,follow')
|
||||
|
||||
@push('structured_data')
|
||||
@if ($searchSchema !== null)
|
||||
<script type="application/ld+json">
|
||||
@json($searchSchema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
|
||||
</script>
|
||||
@endif
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
@include('partials.breadcrumbs', [
|
||||
'items' => [
|
||||
['label' => 'Главная', 'url' => route('home')],
|
||||
['label' => 'Поиск', 'url' => null],
|
||||
],
|
||||
])
|
||||
|
||||
<section class="pc-section">
|
||||
<div class="pc-category-toolbar">
|
||||
<div class="pc-section-title">
|
||||
<h2>{{ $searchQuery !== '' ? 'Результаты поиска' : 'Поиск товаров' }}</h2>
|
||||
<p>
|
||||
@if ($searchQuery !== '')
|
||||
Запрос: "{{ $searchQuery }}"
|
||||
@else
|
||||
Введите название товара, чтобы увидеть найденные позиции.
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if ($searchQuery !== '')
|
||||
<form class="pc-sort-form" method="get" action="{{ route('search.index') }}">
|
||||
<input type="hidden" name="q" value="{{ $searchQuery }}">
|
||||
<label for="sort">Сортировка:</label>
|
||||
<select id="sort" name="sort" onchange="this.form.submit()">
|
||||
<option value="newest" @selected($sort === 'newest')>Сначала новые</option>
|
||||
<option value="price_asc" @selected($sort === 'price_asc')>Сначала дешевле</option>
|
||||
<option value="price_desc" @selected($sort === 'price_desc')>Сначала дороже</option>
|
||||
<option value="name_asc" @selected($sort === 'name_asc')>По названию</option>
|
||||
</select>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<form class="pc-search-page-form" method="get" action="{{ route('search.index') }}">
|
||||
<div class="pc-search">
|
||||
<input type="text" name="q" placeholder="Например, Ryzen 7 или RTX 4060" value="{{ $searchQuery }}">
|
||||
</div>
|
||||
<button class="pc-btn primary" type="submit">Найти</button>
|
||||
@if ($searchQuery !== '')
|
||||
<a class="pc-btn ghost" href="{{ route('search.index') }}">Очистить</a>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@if ($searchQuery === '')
|
||||
<div class="pc-card">
|
||||
Введите запрос в строку поиска, чтобы открыть список найденных товаров.
|
||||
</div>
|
||||
@else
|
||||
<p class="pc-muted">Найдено товаров: <strong>{{ $products->total() }}</strong></p>
|
||||
|
||||
<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>
|
||||
@endif
|
||||
</section>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user