@php $allListingsCount = isset($allListingsTotal) ? (int) $allListingsTotal : (int) $listings->total(); $resultListingsCount = isset($filteredListingsTotal) ? (int) $filteredListingsTotal : (int) $listings->total(); $activeCategoryName = $selectedCategory?->name ? trim((string) $selectedCategory->name) : ''; $seoHeading = $activeCategoryName !== '' ? $activeCategoryName.' Listings and Prices' : 'All Listings and Prices'; $canSaveSearch = $search !== '' || ! is_null($categoryId); $normalizeQuery = static fn ($value): bool => ! is_null($value) && $value !== ''; $baseCategoryQuery = array_filter([ 'search' => $search !== '' ? $search : null, 'user' => $sellerUserId ?? null, 'country' => $countryId, 'city' => $cityId, 'min_price' => $minPriceInput !== '' ? $minPriceInput : null, 'max_price' => $maxPriceInput !== '' ? $maxPriceInput : null, 'date_filter' => $dateFilter !== 'all' ? $dateFilter : null, 'sort' => $sort !== 'smart' ? $sort : null, ], $normalizeQuery); $clearFiltersQuery = array_filter([ 'search' => $search !== '' ? $search : null, 'user' => $sellerUserId ?? null, ], $normalizeQuery); $activeFilterCount = collect([ $categoryId, $countryId, $cityId, $sellerUserId, $minPriceInput !== '' ? $minPriceInput : null, $maxPriceInput !== '' ? $maxPriceInput : null, $dateFilter !== 'all' ? $dateFilter : null, ])->filter($normalizeQuery)->count(); @endphp

{{ $seoHeading }}

@if($search !== '') @endif @if($categoryId) @endif @if(! empty($sellerUserId)) @endif @if($countryId) @endif @if($cityId) @endif @if($minPriceInput !== '') @endif @if($maxPriceInput !== '') @endif @if($dateFilter !== 'all') @endif

{{ number_format($resultListingsCount) }} {{ $activeCategoryName !== '' ? ' listings in '.$activeCategoryName : ' listings found' }}

@if($listings->isEmpty())
No listings match this filter.
@else
@foreach($listings as $listing) @php $listingImage = $listing->primaryImageData('card'); $isFavorited = in_array($listing->id, $favoriteListingIds ?? [], true); $priceValue = ! is_null($listing->price) ? (float) $listing->price : null; $locationParts = array_filter([ trim((string) ($listing->city ?? '')), trim((string) ($listing->country ?? '')), ], fn ($value) => $value !== ''); $locationText = implode(', ', $locationParts); @endphp
@if($listingImage) @include('listing::partials.responsive-image', [ 'image' => $listingImage, 'alt' => $listing->title, 'class' => 'w-full h-full object-cover', ]) @else @endif @if($listing->is_featured) Featured @endif
@auth
@csrf
@else @endauth

@if(!is_null($priceValue) && $priceValue > 0) {{ number_format($priceValue, 0) }} {{ $listing->currency }} @else Free @endif

{{ $listing->title }}

{{ $listing->category?->name ?: 'No category' }}

{{ $locationText !== '' ? $locationText : 'Location not specified' }} {{ $listing->created_at?->format('M j, Y') }}
@endforeach
@endif
{{ $listings->links() }}