@if (is_plugin_active('marketplace')) @php /** * Vendor list partial. * Used as both server-render in views/marketplace/stores.blade.php AND as * AJAX fragment for infinite scroll / load-more. * * Inputs: * $stores iterable<\Botble\Marketplace\Models\Store> (required) */ $reviewsEnabled = class_exists(\Botble\Ecommerce\Facades\EcommerceHelper::class) && \Botble\Ecommerce\Facades\EcommerceHelper::isReviewEnabled(); $hideAddress = class_exists(\Botble\Marketplace\Facades\MarketplaceHelper::class) && \Botble\Marketplace\Facades\MarketplaceHelper::hideStoreAddress(); // Batch-resolve product counts in a single query — plugin's PublicStoreController // doesn't withCount('products'), so we attach it theme-side without N+1. $storeItems = method_exists($stores, 'items') ? $stores->items() : (is_iterable($stores) ? $stores : []); $storeIds = collect($storeItems)->pluck('id')->filter()->all(); $countsByStore = $storeIds ? \Botble\Ecommerce\Models\Product::query() ->whereIn('store_id', $storeIds) ->where('is_variation', 0) ->wherePublished() ->selectRaw('store_id, COUNT(*) as c') ->groupBy('store_id') ->pluck('c', 'store_id') : collect(); @endphp @if ((is_countable($stores) ? count($stores) : 0) > 0)
@foreach ($stores as $store) @php($productsCount = (int) ($countsByStore[$store->id] ?? 0))
{!! \Botble\Media\Facades\RvMedia::image( $store->logo, $store->name, 'thumb', true, ['class' => 'marketplace-vendor-card__avatar-img'] ) !!}
{{ $store->name }} @if (! empty($store->badge)) {!! \Botble\Base\Facades\BaseHelper::clean($store->badge) !!} @endif
@if ($reviewsEnabled && method_exists($store, 'reviews'))
@includeIf(\Botble\Ecommerce\Facades\EcommerceHelper::viewPath('includes.rating-star'), ['avg' => (float) ($store->reviews()->avg('star') ?? 0)])
@endif

{{ $productsCount === 1 ? __('1 product') : __(':count products', ['count' => number_format($productsCount)]) }}

@if (! $hideAddress && ! empty($store->full_address))

{{ $store->full_address }}

@endif {{ __('Visit store') }}
@endforeach
@else

{{ __('No vendors found.') }}

@endif @endif