@php use App\Models\AdminCategory; use App\Models\AdminReview; use App\Models\BlogPost; $channel = core()->getCurrentChannel(); // Helper baca config editable $c = fn(string $k, string $default = '') => (string) (core()->getConfigData("beres_storefront.$k") ?: $default); // Palette hijau untuk placeholder produk yang belum punya gambar $bgPool = ['#E8F0E5','#DCE8D6','#F0F5EC','#EAF1E4','#F5F9F3','#C8DBBE']; $bgPick = fn(int $i) => $bgPool[$i % count($bgPool)]; // ============ HOMEPAGE HIGHLIGHTS — via HomepageHighlightService ============ $highlightService = app(\Beres\Highlight\Services\HomepageHighlightService::class); $sectionLimits = \Beres\Highlight\Models\HomepageHighlight::getSectionDefinitions(); try { $newProductsDb = $highlightService->getProducts(\Beres\Highlight\Models\HomepageHighlight::SECTION_NEW_ARRIVALS, $sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_NEW_ARRIVALS]['limit']); $featuredProduct = $highlightService->getFeaturedProduct(); $bundlesDb = $highlightService->getProducts(\Beres\Highlight\Models\HomepageHighlight::SECTION_KITS_BUNDLES, $sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_KITS_BUNDLES]['limit']); $bestSellersDb = $highlightService->getProducts(\Beres\Highlight\Models\HomepageHighlight::SECTION_BEST_SELLERS, $sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_BEST_SELLERS]['limit']); $superfoodsDb = $highlightService->getProducts(\Beres\Highlight\Models\HomepageHighlight::SECTION_SEEDS, $sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_SEEDS]['limit']); } catch (\Throwable $e) { $newProductsDb = collect(); $featuredProduct = null; $bundlesDb = collect(); $bestSellersDb = collect(); $superfoodsDb = collect(); } // ============ CATEGORIES — from admin_categories ============ try { $categoriesDb = $highlightService->getCategories($sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_CATEGORIES]['limit']); } catch (\Throwable $e) { $categoriesDb = AdminCategory::withCount('products')->orderByDesc('products_count')->limit($sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_CATEGORIES]['limit'])->get() ->map(fn ($cat) => ['id' => $cat->id, 'name' => $cat->name, 'slug' => $cat->slug, 'image' => $cat->image ? asset('storage/'.$cat->image) : null]); } // ============ REVIEWS — from admin_reviews (approved only) ============ try { $reviewsDb = AdminReview::with('product') ->where('is_approved', true) ->orderBy('created_at', 'desc') ->limit(3)->get(); } catch (\Throwable $e) { $reviewsDb = collect(); } // ============ BLOGS — from blog_posts (published only) ============ try { $blogsDb = BlogPost::with('category') ->where('is_published', true) ->orderBy('published_at', 'desc') ->limit(3)->get(); } catch (\Throwable $e) { $blogsDb = collect(); } // Trust badges (editable via admin) $trustBadges = array_values(array_filter([ [core()->getConfigData('beres_storefront.trust.badge1_title'), core()->getConfigData('beres_storefront.trust.badge1_desc')], [core()->getConfigData('beres_storefront.trust.badge2_title'), core()->getConfigData('beres_storefront.trust.badge2_desc')], [core()->getConfigData('beres_storefront.trust.badge3_title'), core()->getConfigData('beres_storefront.trust.badge3_desc')], [core()->getConfigData('beres_storefront.trust.badge4_title'), core()->getConfigData('beres_storefront.trust.badge4_desc')], ], fn($b) => !empty($b[0]))); // ============ FAQS — from faqs table in database ============ try { $faqsDb = \App\Models\Faq::where('is_active', true)->orderBy('sort_order')->latest()->get(); } catch (\Throwable $e) { $faqsDb = collect(); } @endphp @php $siteName = $channel->name ?? config('app.name'); $homeTitle = $channel->home_seo['meta_title'] ?? "$siteName — Belanja bahan segar dan pantry esensial"; $homeDesc = $channel->home_seo['meta_description'] ?? 'Pasar online untuk bahan segar dan pantry esensial. Langsung dari petani dan produsen lokal.'; $homeUrl = route('shop.home.index'); $homeOgImage = $channel->logo_url ?? null; @endphp @push('styles') @endpush @push('scripts') @endpush @push('meta') @if ($homeOgImage)@endif @endPush {{ $channel->home_seo['meta_title'] ?? '' }} {{-- ============ HERO CAROUSEL ============ --}} @php $heroBannerSetting = null; try { $heroBannerSetting = \App\Models\SiteSetting::getValue('hero_banner_image'); } catch (\Throwable $e) {} $heroSlides = array_values(array_filter([ $heroBannerSetting ?: ($c('hero.slide1_img') ?: (file_exists(public_path('images/hero-products.jpg')) ? '/images/hero-products.jpg' : '')), $c('hero.slide2_img'), $c('hero.slide3_img'), $c('hero.slide4_img'), ])); @endphp @if (!empty($heroSlides))
@foreach ($heroSlides as $i => $img)
Slide {{ $i + 1 }}
@endforeach
@if (count($heroSlides) > 1)
@foreach ($heroSlides as $i => $img) @endforeach
@endif
@else {{-- Skeleton placeholder ketika belum ada gambar hero slide --}}
Banner Toko (Upload di Pengaturan)
@endif {{-- Style & script hero dipindah ke @push di bawah supaya tidak di-drop oleh Vue --}} {{-- ============ FEATURED PRODUCT SPOTLIGHT ============ --}} @if ($featuredProduct) @php $fpName = $featuredProduct->name ?? $featuredProduct->url_key ?? 'Featured Product'; if ($featuredProduct instanceof \App\Models\AdminProduct) { $fpPrice = 'Rp ' . number_format($featuredProduct->price ?? 0, 0, ',', '.'); $fpUrl = route('shop.admin_product.show', $featuredProduct->slug ?? '#'); $fpImage = $featuredProduct->image_url ?? ($featuredProduct->images && $featuredProduct->images->count() ? $featuredProduct->images->first()->card_url : null); $fpDesc = $featuredProduct->description ?? null; } else { $minP = 0; try { $minP = $featuredProduct->getTypeInstance()->getMinimalPrice() ?? 0; } catch (\Throwable $e) {} $fpPrice = 'Rp ' . number_format($minP, 0, ',', '.'); $fpUrl = $featuredProduct->url_key ? route('shop.product_or_category.index', $featuredProduct->url_key) : route('shop.search.index'); $fpImage = product_image()->getProductBaseImage($featuredProduct)['medium_image_url'] ?? null; $fpDesc = $featuredProduct->short_description ?? null; } @endphp

{{ $fpName }}

{{ $fpPrice }}

@if (!empty($fpDesc))
@if ($featuredProduct instanceof \App\Models\AdminProduct)

{{ $fpDesc }}

@else {!! $fpDesc !!} @endif
@endif
@csrf Beli Sekarang
Lihat detail lengkap
@endif {{-- ============ NEW ARRIVALS ============ --}} @if ($newProductsDb->isNotEmpty())

{{ $c('sections.new_title', 'Produk Terbaru') }}

@endif {{-- ============ KITS & BUNDLES ============ --}} @if ($bundlesDb->isNotEmpty())

{{ $c('sections.bundle_title', 'Paket & Bundel') }}

@endif {{-- ============ 100% NATURAL BANNER ============ --}} @php $naturalLink = $c('natural_banner.link', ''); @endphp
@if($naturalLink) @endif
@for ($rep = 0; $rep < 6; $rep++) {{ $c('natural_banner.text1', '100% ALAMI') }} {{ $c('natural_banner.text2', 'BERSERTIFIKAT LAB') }} @endfor
@if($naturalLink)
@endif
{{-- ============ SHOP BY CATEGORY ============ --}} @php $homeCats = app(\Beres\Highlight\Services\HomepageHighlightService::class) ->getCategories($sectionLimits[\Beres\Highlight\Models\HomepageHighlight::SECTION_CATEGORIES]['limit']); @endphp @if ($homeCats->isNotEmpty())

{{ $c('sections.cat_title', 'All Kitchen Needs') }}

See All Categories
{{-- Horizontal scroll row — single row on desktop --}}
@endif {{-- ============ ALL TIME BEST SELLER ============ --}} @if ($bestSellersDb->isNotEmpty())

{{ $c('sections.best_title', 'Produk Terlaris') }}

@endif {{-- ============ CATEGORY TICKER (Marquee - Only if categories exist in DB) ============ --}} @php $tickerDbCats = \App\Models\AdminCategory::pluck('name')->all(); @endphp @if(!empty($tickerDbCats))
@for ($rep = 0; $rep < 4; $rep++) @foreach ($tickerDbCats as $t) {{ $t }} @endforeach @endfor
@endif {{-- ============ SEEDS & SUPERFOODS ============ --}} @if ($superfoodsDb->isNotEmpty())

{{ $c('sections.seed_title', 'Biji & Superfood Kami') }}

Lihat Semua
@endif {{-- Empty catalog notice when no products exist --}} @if ($newProductsDb->isEmpty() && $bundlesDb->isEmpty() && $bestSellersDb->isEmpty() && $superfoodsDb->isEmpty() && !$featuredProduct)

Katalog Produk Segera Hadir

Saat ini belum ada produk aktif yang ditampilkan. Silakan tambahkan produk baru melalui panel admin.

@endif {{-- ============ TRUST BADGES with icons ============ --}} @if (!empty($trustBadges))
@php $badgeIcons = [ // Pick Up — storefront '', // Fastest Delivery — truck '', // Best Offer Zone — tag '', // Best Quality — shield/check '', ]; @endphp @foreach ($trustBadges as $i => [$title, $desc])
{!! $badgeIcons[$i % 4] !!}

{{ $title }}

{{ $desc }}

@endforeach
@endif {{-- ============ CUSTOMER REVIEWS (Only show if real approved reviews exist in DB) ============ --}} @if ($reviewsDb->isNotEmpty())

{{ $c('sections.review_title', 'Ulasan Pelanggan') }}

Tulis ulasan
@foreach ($reviewsDb as $review) @php $revName = $review->customer_name ?? 'Anonim'; $revInitial = strtoupper(mb_substr($revName, 0, 1)); $revText = $review->comment ?? $review->title ?? ''; $revStars = str_repeat('★', (int) ($review->rating ?? 5)) . str_repeat('☆', 5 - (int) ($review->rating ?? 5)); @endphp

{{ $revStars }}

"{{ $revText }}"

{{ $revInitial }} {{ $revName }}
@endforeach
@endif {{-- ============ GOOGLE REVIEWS (Empty State — ready for Google Business Profile integration) ============ --}} @php $googleReviews = []; $googleRating = 0; $googleReviewCount = 0; $googleReviewUrl = $c('contact.google_review_url', 'https://www.google.com/search?q=Ankesh+Online+Store'); @endphp
{{-- Header --}}

{{ $c('sections.google_review_title', 'Ulasan Google Pelanggan') }}

@if ($googleReviewCount > 0)
@for ($i = 1; $i <= 5; $i++) @if ($i <= floor($googleRating)) @elseif ($i - $googleRating < 1 && $i - $googleRating > 0) @else @endif @endfor
{{ number_format($googleRating, 1) }} ({{ number_format($googleReviewCount) }} ulasan)
@endif
Tulis Ulasan
{{-- Empty State --}} @if (empty($googleReviews))

Belum ada ulasan Google

Ulasan dari Google Business Profile akan muncul di sini setelah terhubung. Bagikan pengalaman belanja Anda!

Jadilah yang pertama memberi ulasan
@else {{-- Review Cards Horizontal Scroll --}}
@foreach ($googleReviews as $review)
@if (!empty($review['avatar'])) {{ $review['name'] ?? 'Reviewer' }} @else {{ strtoupper(mb_substr($review['name'] ?? 'A', 0, 1)) }} @endif

{{ $review['name'] ?? 'Anonim' }}

{{ $review['time'] ?? '' }}

@for ($i = 1; $i <= 5; $i++) @if ($i <= ($review['rating'] ?? 5)) @else @endif @endfor

{{ $review['text'] ?? '' }}

@endforeach
{{-- See All Link --}} @endif
{{-- ============ FAQ (Only show if real FAQs exist in DB) ============ --}} @if ($faqsDb->isNotEmpty())

{{ $c('sections.faq_title', 'FAQ') }}

@foreach ($faqsDb as $i => $faq)
{{ $faq->question }} +
{!! $faq->answer !!}
@endforeach
@endif {{-- ============ LATEST BLOGS & ARTICLES (Only show if real blogs exist in DB) ============ --}} @if ($blogsDb->isNotEmpty())
{{ $c('sections.blog_eyebrow', 'Artikel & Wawasan') }}

{{ $c('sections.blog_title', 'Artikel & Tips Terbaru') }}

Lihat Semua Artikel
@foreach ($blogsDb as $i => $page) @php $blogTitle = $page->title ?? ''; $blogCategory = $page->category?->name ?? 'Artikel & Tips'; $blogExcerpt = \Illuminate\Support\Str::limit(strip_tags($page->content ?? ''), 120); $blogUrl = $page->slug ? route('shop.blog.show', $page->slug) : '#'; $blogDate = $page->published_at ? $page->published_at->format('d F Y') : ($page->created_at ? $page->created_at->format('d F Y') : ''); $blogImg = $page->thumbnail_url; @endphp @endforeach
@endif {{-- Map & Contact section ditampilkan lewat layout utama (shop::components.layouts.map-section) pada semua halaman, jadi tidak perlu di-include lagi di sini. --}}