@extends('layouts.app') @php use Illuminate\Support\Str; use Illuminate\Support\Facades\Route; $locale = app(\App\Services\Content\ContentLocale::class); $languageId = $locale->languageId(); // Prefer username, fall back to full name, then a safe default. $sellerName = $seller->username ?: trim(($seller->first_name ?? '') . ' ' . ($seller->last_name ?? '')) ?: __('Seller'); $sellerSlug = $seller->slug ?: $seller->id; // Avatar URL $avatarUrl = $seller->avatar ? asset('storage/' . ltrim($seller->avatar, '/')) : null; // Cover URL — fall back to avatar when no cover is uploaded. $coverUrl = $seller->cover_image ? asset('storage/' . ltrim($seller->cover_image, '/')) : $avatarUrl; // Flag so the view can style the fallback cover differently // (blurred / dimmed avatar vs. a real cover image). $isAvatarAsCover = empty($seller->cover_image) && !empty($avatarUrl); $initial = strtoupper(Str::substr($sellerName, 0, 1)); // Role label $roleName = null; if ($seller->relationLoaded('role') && $seller->role) { $raw = $seller->role->role_name; if (is_array($raw)) { $roleName = $raw[0]['name'] ?? null; } elseif (is_string($raw) && str_starts_with($raw, 'a:')) { $decoded = @unserialize($raw, ['allowed_classes' => false]); if (is_array($decoded)) { $roleName = $decoded[0]['name'] ?? null; } } else { $roleName = is_string($raw) ? $raw : null; } } // Seller profile fields $location = trim(collect([ $seller->city_name, $seller->state_name, $seller->country_name, ])->filter()->implode(', ')); $memberSince = $seller->created_at; // Whether the visitor is the seller themselves. $isOwner = auth()->check() && (int) auth()->id() === (int) $seller->id; // Filters + form action (preserve current seller) $storefrontUrl = route('sellers.show', [ 'seller' => $seller->slug, ]); $sortOptions = [ 'latest' => __('Latest'), 'oldest' => __('Oldest'), 'price_low' => __('Price: Low to High'), 'price_high' => __('Price: High to Low'), 'rating' => __('Top Rated'), 'popular' => __('Most Popular'), ]; $activeFilterCount = collect([ $search !== '' ?: null, $selectedType !== '' ?: null, ])->filter()->count(); $wishlistSet = collect($wishlistProductIds)->map(fn ($id) => (int) $id)->all(); @endphp @section('title', $sellerName) @section('meta') @if($coverUrl) @endif @endsection @section('content') {{-- ============ COVER + PROFILE HEADER ============ --}}
@unless($coverUrl)
@endunless
{{-- Avatar --}}
@if($avatarUrl) {{ $sellerName }} @else
{{ $initial }}
@endif
{{-- Identity --}}

{{ $sellerName }}

@if($seller->is_active_shop_request && $seller->email_status) {{ __('Verified Seller') }} @endif @if($roleName) {{ $roleName }} @endif @if($seller->vacation_mode) {{ __('On Vacation') }} @endif
@if($location !== '') {{ $location }} @endif @if($memberSince) {{ __('Joined :date', ['date' => $memberSince->format('M Y')]) }} @endif @if($statistics['average_rating'] > 0) {{ number_format($statistics['average_rating'], 1) }} @endif
{{-- Follow / Unfollow / Owner --}}
@guest {{ __('Follow') }} @endguest @auth @if($isOwner) {{ __('Seller Dashboard') }} @elseif($isFollowing)
@csrf @method('DELETE')
@else
@csrf
@endif @endauth
@if(session('status'))
{{ session('status') }}
@endif @if(session('success'))
{{ session('success') }}
@endif @error('seller')
{{ $message }}
@enderror
{{-- ============ STATISTICS ============ --}}
@php $statCards = [ ['key' => 'products', 'label' => __('Products'), 'value' => number_format($statistics['products']), 'icon' => 'bi-box-seam'], ['key' => 'followers', 'label' => __('Followers'), 'value' => number_format($statistics['followers']), 'icon' => 'bi-people'], ['key' => 'sales', 'label' => __('Sales'), 'value' => number_format($statistics['sales']), 'icon' => 'bi-bag-check'], ['key' => 'views', 'label' => __('Views'), 'value' => number_format($statistics['views']), 'icon' => 'bi-eye'], ['key' => 'average_rating','label' => __('Rating'), 'value' => number_format($statistics['average_rating'], 1), 'icon' => 'bi-star'], ]; @endphp @foreach($statCards as $stat)
{{ $stat['value'] }}
{{ $stat['label'] }}
@endforeach
{{-- ============ ABOUT ============ --}} @if($seller->about_me)
{{ __('About :name', ['name' => $sellerName]) }}

{{ $seller->about_me }}

@endif @if($seller->vacation_mode && $seller->vacation_message)
{{ $seller->vacation_message }}
@endif {{-- ============ FILTERS ============ --}}
@if($activeFilterCount > 0) @endif
{{-- ============ PRODUCT LISTING ============ --}}

{{ __('Products') }} ({{ number_format($products->total()) }})

@if($search !== '') {{ __('Results for ":q"', ['q' => $search]) }} @endif
@if($products->isEmpty())

{{ __('No products found') }}

{{ $search !== '' || $selectedType !== '' ? __('Try adjusting your filters or search terms.') : __('This seller has not published any products yet.') }}

@if($activeFilterCount > 0) {{ __('Reset filters') }} @endif
@else
@foreach($products as $product) @php $detail = $product->details->first(); $image = $product->images->first(); $price = (float) $product->price; $discounted = (float) $product->price_discounted; $hasDiscount = $discounted > 0 && $discounted < $price; $selling = $hasDiscount ? $discounted : $price; $catName = optional($product->category?->translations)->first()?->name ?? $product->category?->slug; $inWishlist = in_array((int) $product->id, $wishlistSet, true); $promoActive = $product->is_promoted && $product->promote_start_date && $product->promote_end_date && $product->promote_start_date <= now() && $product->promote_end_date >= now(); $outOfStock = $product->product_type === 'physical' && (int) $product->stock <= 0; @endphp
@auth @unless((int) auth()->id() === (int) $seller->id) @endunless @endauth @if($promoActive) {{ __('Promoted') }} @endif
@if($image) {{ $detail?->title ?? $product->slug }} @else
@endif

{{ $detail?->title ?? Str::title(str_replace('-', ' ', $product->slug)) }}

@if($detail?->short_description)

{{ Str::limit($detail->short_description, 70) }}

@endif @if($catName)
{{ $catName }}
@endif @if((int) $product->reviews_count > 0)
{{ number_format((float) $product->rating, 1) }} ({{ $product->reviews_count }})
@endif
@if($hasDiscount)
{{ number_format($price, 2) }}
@endif
{{ number_format($selling, 2) }} {{ $product->currency }}
@if($outOfStock) {{ __('Out') }} @endif
@endforeach
{{ $products->links() }}
@endif
@endsection @push('styles') @endpush @push('scripts') @endpush