@extends('welcome') @section('title', __('search.seo_title', ['query' => $query])) @section('meta_description', __('search.meta_description', ['query' => $query])) @section('content')

{{ __('search.page_title') }}

"{{ $query }}"

@if($totalResults > 0) {{ trans_choice('search.results_found', $totalResults, ['count' => $totalResults]) }} @else {{ __('search.no_results_found', ['query' => $query]) }} @endif
@if($totalResults > 0)
{{ __('search.all_results') }} ({{ $totalResults }}) @if(isset($counts['packs']) && $counts['packs'] > 0) {{ __('search.packs') }} ({{ $counts['packs'] }}) @endif @if(isset($counts['vouchers']) && $counts['vouchers'] > 0) {{ __('search.vouchers') }} ({{ $counts['vouchers'] }}) @endif @if(isset($counts['avulsos']) && $counts['avulsos'] > 0) {{ __('search.avulsos') }} ({{ $counts['avulsos'] }}) @endif
@forelse($results as $result) @php $resultType = $result['type'] ?? 'product'; $item = $result['item']; if ($resultType === 'product') { $imageUrl = $item->pro_img ? asset('images/product/' . $item->pro_img) : asset('assets/img/icon/category_card_1.svg'); $title = $item->title ?? $item->description() ?? $item->pro_description_pt ?? ''; $url = $item->pro_slug ? route('packs.show', $item->category->cat_slug) : '#'; $category = $item->category?->description() ?? ''; $categoryType = $item->category?->cat_type ?? ''; $icon = 'fa-box'; $iconColor = 'var(--verde-dona)'; $badgeColor = 'var(--verde-dona)'; if ($categoryType === 'Voucher') { $icon = 'fa-gift'; $iconColor = 'var(--laranja-cta)'; $badgeColor = 'var(--laranja-cta)'; $url = '#'; } elseif (in_array($categoryType, ['Sopa', 'Sobremesa', 'Sumo'])) { $icon = 'fa-utensils'; $iconColor = 'var(--verde-oliva)'; $badgeColor = 'var(--verde-oliva)'; $url = '#'; } $price = null; $priceFormatted = null; if ($categoryType === 'Voucher') { if (isset($item->voucher_price) && $item->voucher_price > 0) { $price = $item->voucher_price; $priceFormatted = $item->voucher_price_formatted ?? number_format($price, 2, ',', ' ') . ' €'; } elseif ($item->relationLoaded('voucherPricePtm') && $item->voucherPricePtm) { $price = $item->voucherPricePtm->ptm_price ?? null; $priceFormatted = $price ? number_format($price, 2, ',', ' ') . ' €' : null; } } elseif ($item->relationLoaded('typeMeals') && $item->typeMeals->isNotEmpty()) { $firstPivot = $item->typeMeals->first()?->pivot; $price = $firstPivot?->ptm_price ?? null; $priceFormatted = $price ? number_format($price, 2, ',', ' ') . ' €' : null; } } else { $imageUrl = asset('assets/img/icon/category_card_1.svg'); $title = ''; $url = '#'; $category = ''; $categoryType = ''; $icon = 'fa-box'; $iconColor = 'var(--verde-dona)'; $badgeColor = 'var(--verde-dona)'; $price = null; $priceFormatted = null; } @endphp
@if($categoryType === 'Voucher') {{ __('search.voucher') }} @elseif(in_array($categoryType, ['Sopa', 'Sobremesa', 'Sumo'])) {{ $categoryType }} @else {{ __('search.pack') }} @endif
{{ $title }}

{{ $title }}

@if($category)

{{ $category }}

@endif @if(isset($result['matches']) && !empty($result['matches']))
{{ __('search.matches') }}: @foreach($result['matches'] as $match) {{ $match }} @endforeach
@endif
@if($price && $price > 0) {{ $priceFormatted ?? number_format($price, 2, ',', ' ') . ' €' }} @endif
{{-- Packs → abrir página --}} @if(!in_array($categoryType, ['Voucher','Sopa','Sobremesa','Sumo'])) {{-- Outros produtos → adicionar ao carrinho --}} @else @endif
@empty

{{ __('search.no_results_in_tab') }}

@endforelse
@else

{{ __('search.suggestions_title') }}

{{ __('search.packs') }} {{ __('search.vouchers') }} {{ __('search.soups') }} {{ __('search.desserts') }} {{ __('search.juices') }}

{{ __('search.try_different_keywords') }}

{{ __('search.browse_packs') }}
@endif
@if($results->hasPages())
@endif @endsection @push('styles') @endpush @push('scripts') @endpush