Files
tehnobox/resources/views/partials/product-card.blade.php
ssww23 0ee9f05416
Some checks failed
Deploy / deploy (push) Has been cancelled
1
2026-03-17 01:59:00 +03:00

61 lines
3.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@php
$favoriteIds = array_map('intval', (array) session('favorites', []));
$compareIds = array_map('intval', (array) session('compare', []));
$isFavorite = in_array($product->id, $favoriteIds, true);
$isCompared = in_array($product->id, $compareIds, true);
$cartItems = (array) session('cart', []);
$isInCart = isset($cartItems[$product->id]);
@endphp
<article class="pc-card pc-product-card">
<div class="pc-product-media">
<div class="pc-product-tools">
<form method="post" action="{{ route('favorites.toggle', $product) }}" class="pc-product-tool-form" data-preserve-scroll="true">
@csrf
<button class="pc-product-tool {{ $isFavorite ? 'is-active' : '' }}" type="submit" aria-label="{{ __('Добавить в избранное') }}" title="{{ __('В избранное') }}">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 20s-7-4.5-9-9c-1.2-2.7.7-6 4.2-6 2 0 3.2 1 3.8 2 0.6-1 1.8-2 3.8-2 3.5 0 5.4 3.3 4.2 6-2 4.5-9 9-9 9z"></path>
</svg>
</button>
</form>
<form method="post" action="{{ route('compare.toggle', $product) }}" class="pc-product-tool-form" data-preserve-scroll="true">
@csrf
<button class="pc-product-tool {{ $isCompared ? 'is-active' : '' }}" type="submit" aria-label="{{ __('Добавить в сравнение') }}" title="{{ __('Сравнить') }}">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 4h3v16H5zM16 4h3v16h-3zM10.5 8h3v12h-3z"></path>
</svg>
</button>
</form>
</div>
@if (!empty($product->image_url))
<img class="pc-product-image" src="{{ $product->image_url }}" alt="{{ $product->name }}" loading="lazy" decoding="async">
@else
<div class="pc-product-image" role="img" aria-label="{{ $product->name }}"></div>
@endif
</div>
<h3>
<a class="pc-product-link" href="{{ route('products.show', $product) }}">{{ $product->name }}</a>
</h3>
@if (!empty($product->short_description))
<p>{{ __($product->short_description) }}</p>
@endif
<div class="pc-product-meta">
<strong>{{ number_format($product->price, 0, '.', ' ') }} {{ config('shop.currency_symbol', '₽') }}</strong>
@if (!empty($product->old_price))
<span class="pc-product-old">{{ number_format($product->old_price, 0, '.', ' ') }} {{ config('shop.currency_symbol', '₽') }}</span>
@endif
</div>
<div class="pc-product-actions">
@if ($product->stock > 0)
<form method="post" action="{{ route('cart.add', $product) }}" data-preserve-scroll="true">
@csrf
<button class="pc-btn ghost {{ $isInCart ? 'is-active' : '' }}" type="submit">
{{ $isInCart ? __('В корзине') : __('В корзину') }}
</button>
</form>
@else
<button class="pc-btn ghost" type="button" disabled>{{ __('Нет в наличии') }}</button>
@endif
</div>
</article>