113 lines
5.1 KiB
PHP
113 lines
5.1 KiB
PHP
@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' => __('Результаты поиска: :query', ['query' => $searchQuery]),
|
|
'url' => route('search.index', ['q' => $searchQuery]),
|
|
'mainEntity' => [
|
|
'@type' => 'ItemList',
|
|
'numberOfItems' => $products->total(),
|
|
'itemListElement' => $searchItemList,
|
|
],
|
|
]
|
|
: null;
|
|
@endphp
|
|
|
|
@section('meta_title', $searchQuery !== '' ? __('Поиск: :query', ['query' => $searchQuery]) : __('Поиск товаров'))
|
|
@section(
|
|
'meta_description',
|
|
$searchQuery !== ''
|
|
? __('Найденные товары по запросу «:query». Выберите подходящий товар и откройте подробную карточку.', ['query' => $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 !== '')
|
|
{{ __('Запрос: ":query"', ['query' => $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
|