@php /* |-------------------------------------------------------------------------- | Theme |-------------------------------------------------------------------------- */ $theme = array_merge( [ 'primary' => '#4f9000', 'primary_dark' => '#3c7000', 'secondary' => '#68b900', 'accent' => '#ffbd00', 'accent_dark' => '#eaa900', 'light_green' => '#efffd3', 'cream' => '#fff8e4', 'surface' => '#ffffff', 'text' => '#121212', 'muted' => '#6b7280', 'border' => '#d7dce1', ], (array) ($landingPage->theme ?? []) ); /* |-------------------------------------------------------------------------- | SEO |-------------------------------------------------------------------------- */ $seo = (array) ($landingPage->seo ?? []); $metaTitle = data_get($seo, 'meta_title') ?: $landingPage->title ?: $product->name; $metaDescription = data_get($seo, 'meta_description') ?: \Illuminate\Support\Str::limit( strip_tags( (string) ( $product->short_description ?: $product->name ) ), 160 ); /* |-------------------------------------------------------------------------- | Media resolver |-------------------------------------------------------------------------- */ $mediaUrl = function (mixed $reference): ?string { if (is_array($reference)) { $reference = data_get($reference, 'path') ?: data_get($reference, 'url') ?: data_get($reference, 'image') ?: data_get($reference, 'image_path'); } $reference = trim((string) $reference); if ($reference === '') { return null; } if ( method_exists( \App\Models\LandingPage::class, 'resolveMediaUrl' ) ) { return \App\Models\LandingPage::resolveMediaUrl( $reference ); } if ( preg_match( '#^https?://#i', $reference ) ) { $path = parse_url( $reference, PHP_URL_PATH ); if ( is_string($path) && str_starts_with( $path, '/storage/' ) ) { return $path; } return $reference; } if ( str_starts_with( $reference, '/storage/' ) ) { return $reference; } if ( str_starts_with( $reference, 'storage/' ) ) { return '/' . $reference; } return '/storage/' . ltrim( $reference, '/' ); }; /* |-------------------------------------------------------------------------- | Product media |-------------------------------------------------------------------------- */ $productMediaUrl = function (mixed $reference) use ($mediaUrl): ?string { if (blank($reference)) { return null; } if ( method_exists( \App\Models\Product::class, 'resolveMediaUrl' ) ) { $resolved = \App\Models\Product::resolveMediaUrl( $reference ); if ( is_string($resolved) && preg_match( '#^https?://#i', $resolved ) ) { $path = parse_url( $resolved, PHP_URL_PATH ); if ( is_string($path) && str_starts_with( $path, '/storage/' ) ) { return $path; } } return $resolved; } return $mediaUrl($reference); }; /* |-------------------------------------------------------------------------- | Sections |-------------------------------------------------------------------------- */ $allSections = collect( $sections ?? [] ); $orderedSections = $allSections ->filter( fn ($section) => (bool) $section->is_enabled ) ->sortBy('sort_order') ->values(); $heroSection = $allSections->firstWhere( 'type', 'hero' ); $benefitsSection = $allSections->firstWhere( 'type', 'benefits' ); $promoSection = $allSections->firstWhere( 'type', 'promo' ); $usageSection = $allSections->firstWhere( 'type', 'usage' ); $reviewsSection = $allSections->firstWhere( 'type', 'reviews' ); $orderSection = $allSections->firstWhere( 'type', 'order' ); $footerSection = $allSections->firstWhere( 'type', 'footer' ); $hero = (array) ( $heroSection?->content ?? [] ); $benefitsContent = (array) ( $benefitsSection?->content ?? [] ); $promo = (array) ( $promoSection?->content ?? [] ); $usage = (array) ( $usageSection?->content ?? [] ); $reviews = (array) ( $reviewsSection?->content ?? [] ); $orderContent = (array) ( $orderSection?->content ?? [] ); $footer = (array) ( $footerSection?->content ?? [] ); /* |-------------------------------------------------------------------------- | Product images |-------------------------------------------------------------------------- */ $productImages = collect( $product->images ?? [] ) ->map( function ($image) use ($productMediaUrl) { if ( filled( $image->image_path ?? null ) ) { return $productMediaUrl( $image->image_path ); } return $image->url ?? null; } ) ->filter() ->unique() ->values(); $productMainImage = null; if ( filled( $product->cover_image ?? null ) ) { $productMainImage = $productMediaUrl( $product->cover_image ); } if (blank($productMainImage)) { $productMainImage = $productImages->first(); } /* |-------------------------------------------------------------------------- | Hero images |-------------------------------------------------------------------------- */ $heroImages = collect( data_get( $hero, 'gallery_images', [] ) ) ->map( function ($reference) use ( $mediaUrl, $product ) { $url = $mediaUrl( $reference ); if (!$url) { return null; } return [ 'url' => $url, 'alt' => $product->name, ]; } ) ->filter() ->unique('url') ->values(); if ($heroImages->isEmpty()) { collect([ data_get( $hero, 'main_image_url' ), data_get( $hero, 'side_image_1_url' ), data_get( $hero, 'side_image_2_url' ), ]) ->filter() ->each( function ($reference) use ( &$heroImages, $mediaUrl, $product ) { $url = $mediaUrl( $reference ); if ($url) { $heroImages->push([ 'url' => $url, 'alt' => $product->name, ]); } } ); } if ($heroImages->isEmpty()) { foreach ( $productImages as $url ) { $heroImages->push([ 'url' => $url, 'alt' => $product->name, ]); } } if ( $heroImages->isEmpty() && $productMainImage ) { $heroImages->push([ 'url' => $productMainImage, 'alt' => $product->name, ]); } /* |-------------------------------------------------------------------------- | Customer avatars |-------------------------------------------------------------------------- */ $customerAvatars = collect( data_get( $hero, 'customer_avatars', [] ) ) ->map( fn ($reference) => $mediaUrl($reference) ) ->filter() ->unique() ->values(); /* |-------------------------------------------------------------------------- | Benefits |-------------------------------------------------------------------------- */ $benefits = collect( data_get( $benefitsContent, 'items', [] ) ) ->filter() ->values(); while ( $benefits->count() < 6 ) { $benefits->push( 'পণ্যের সুবিধা এখানে লিখুন' ); } /* |-------------------------------------------------------------------------- | Promo |-------------------------------------------------------------------------- */ $promoImage = $mediaUrl( data_get( $promo, 'image' ) ?: data_get( $promo, 'image_url' ) ); if (!$promoImage) { $promoImage = $productImages->get( 1, $productMainImage ); } /* |-------------------------------------------------------------------------- | Usage |-------------------------------------------------------------------------- */ $usageFeatures = collect( data_get( $usage, 'features', [] ) ) ->filter() ->values(); if ($usageFeatures->isEmpty()) { $usageFeatures = collect([ 'কৃত্রিম উপাদান নেই', 'প্রাকৃতিক উপাদান', 'প্রমাণিত ভেষজ প্রণালী', ]); } /* |-------------------------------------------------------------------------- | Reviews |-------------------------------------------------------------------------- */ $reviewScreenshots = collect( data_get( $reviews, 'screenshots', [] ) ) ->map( fn ($reference) => $mediaUrl($reference) ) ->filter() ->unique() ->values(); if ($reviewScreenshots->isEmpty()) { $reviewScreenshots = collect( data_get( $reviews, 'items', [] ) ) ->map( function ($item) use ($mediaUrl) { return $mediaUrl( data_get( $item, 'image' ) ?: data_get( $item, 'image_url' ) ); } ) ->filter() ->unique() ->values(); } /* |-------------------------------------------------------------------------- | Product variants |-------------------------------------------------------------------------- */ $variants = collect( $product->activeVariants ?? [] ); $defaultVariant = $variants->firstWhere( 'is_default', true ) ?: $variants->first(); if ( $product->has_variants && $defaultVariant ) { $initialPrice = (float) ( $defaultVariant->sale_price ?? $defaultVariant->regular_price ?? 0 ); $initialRegularPrice = (float) ( $defaultVariant->regular_price ?? $initialPrice ); } else { $initialPrice = (float) ( $product->sale_price ?? $product->regular_price ?? 0 ); $initialRegularPrice = (float) ( $product->regular_price ?? $initialPrice ); } /* |-------------------------------------------------------------------------- | Maximum quantity |-------------------------------------------------------------------------- */ $maxQuantity = 100; if (!$product->pre_order_enabled) { if ( $product->has_variants && $defaultVariant && $defaultVariant->track_stock ) { $maxQuantity = max( 1, min( 100, (int) $defaultVariant ->stock_quantity ) ); } elseif ( !$product->has_variants && $product->track_stock ) { $maxQuantity = max( 1, min( 100, (int) $product ->stock_quantity ) ); } } /* |-------------------------------------------------------------------------- | Order product options |-------------------------------------------------------------------------- */ $productOptions = collect(); if ( $product->has_variants && $variants->isNotEmpty() ) { foreach ( $variants as $variant ) { $price = (float) ( $variant->sale_price ?? $variant->regular_price ?? 0 ); $regularPrice = (float) ( $variant->regular_price ?? $price ); $maximum = 100; if ( !$product->pre_order_enabled && $variant->track_stock ) { $maximum = max( 1, min( 100, (int) $variant ->stock_quantity ) ); } $image = $productMainImage; if ( filled( $variant->image ?? null ) ) { $image = $productMediaUrl( $variant->image ); } $productOptions->push([ 'variant_id' => $variant->id, 'name' => $variant->name, 'description' => $variant->description ?? null, 'price' => $price, 'regular_price' => $regularPrice, 'max_quantity' => $maximum, 'image' => $image, 'selected' => $defaultVariant && (int) $defaultVariant->id === (int) $variant->id, ]); } } else { $productOptions->push([ 'variant_id' => null, 'name' => $product->name, 'description' => strip_tags( (string) ( $product->short_description ?? '' ) ), 'price' => $initialPrice, 'regular_price' => $initialRegularPrice, 'max_quantity' => $maxQuantity, 'image' => $productMainImage, 'selected' => true, ]); } /* |-------------------------------------------------------------------------- | Delivery |-------------------------------------------------------------------------- */ $deliveryAreaList = collect( $deliveryAreas ?? [] ) ->values(); $landingPageFreeShipping = filter_var( data_get( $orderContent, 'free_shipping', false ), FILTER_VALIDATE_BOOLEAN ); /* |-------------------------------------------------------------------------- | Footer & WhatsApp |-------------------------------------------------------------------------- */ $whatsapp = preg_replace( '/\D+/', '', (string) data_get( $footer, 'whatsapp_number', '' ) ); $phone = preg_replace( '/\D+/', '', (string) data_get( $footer, 'phone_number', $whatsapp ) ); /* |-------------------------------------------------------------------------- | JS config |-------------------------------------------------------------------------- */ $landingJs = [ 'preview' => (bool) ( $previewMode ?? false ), 'pageId' => (int) $landingPage->id, 'productId' => (int) $product->id, 'productName' => $product->name, 'basePrice' => $initialPrice, 'maxQuantity' => $maxQuantity, 'freeShipping' => $landingPageFreeShipping, 'heroImages' => $heroImages ->values() ->all(), 'reviewImages' => $reviewScreenshots ->values() ->all(), 'csrf' => csrf_token(), 'quoteUrl' => route( 'landing-pages.quote', $landingPage ), 'incompleteUrl' => route( 'landing-pages.incomplete', $landingPage ), 'orderUrl' => route( 'landing-pages.order', $landingPage ), 'successTitle' => data_get( $orderContent, 'success_title', 'অর্ডার সফল হয়েছে' ), 'successText' => data_get( $orderContent, 'success_text', 'ধন্যবাদ। আপনার অর্ডার সফলভাবে গ্রহণ করা হয়েছে।' ), ]; @endphp {{ $metaTitle }} @if($previewMode ?? false)
ADMIN PREVIEW MODE — এখানে Order submit হবে না
@endif
@foreach($orderedSections as $section) @php $content = (array) $section->content; @endphp {{-- ================================================================ HERO ================================================================= --}} @if($section->type === 'hero')
{{ data_get($content, 'brand_name', 'Takfree') }}

{{ data_get($content, 'title_1', 'মাত্র ২১ দিনেই') }} {{ data_get($content, 'title_2', 'ব্যথা থেকে স্বস্তি মিলবে') }} {{ data_get($content, 'title_3', $product->name) }}

{{ data_get($content, 'promise_text', strip_tags((string) ($product->short_description ?: 'আপনার পণ্যের প্রধান সুবিধা এখানে লিখুন'))) }}
{{ data_get($content, 'refund_text', 'উপকার না পেলে ১০০% টাকা ফেরত') }}
{{ data_get($content, 'customer_heading', 'উপকৃত হয়েছেন') }}
@if($customerAvatars->isNotEmpty())
@foreach($customerAvatars->take(4) as $avatar)
Customer
@endforeach
@endif
০২
লক্ষ+
{{ data_get($content, 'customer_count', 'কাস্টমারস') }}
{{-- ================================================================ BENEFITS (REDESIGNED) ================================================================= --}} @elseif($section->type === 'benefits')

{{ data_get($content, 'heading', $product->name) }}

{{ data_get($content, 'subheading', 'যে সমস্যা গুলোর সমাধান করে') }}

{{ data_get($content, 'left_top_label', 'প্রকৃতির স্পর্শে') }} {{ data_get($content, 'right_top_label', 'শরীরের সুস্থতা') }}
@if(filled($productMainImage)) {{ $product->name }} @endif
LAB
TESTED
{{ $benefits->get(0) }}
{{ $benefits->get(3) }}
{{ $benefits->get(1) }}
{{ $benefits->get(4) }}
{{ $benefits->get(2) }}
{{ $benefits->get(5) }}
{{-- ================================================================ PROMO ================================================================= --}} @elseif($section->type === 'promo') @if(filled($promoImage))
{{ $product->name }}
@endif {{-- ================================================================ USAGE ================================================================= --}} @elseif($section->type === 'usage')

{{ data_get($content, 'title', 'সহজ ব্যবহারবিধি') }}

{{ data_get($content, 'text', 'প্রতিদিন সকাল ও রাতে শরীরের ব্যথা আক্রান্ত স্থানে') }} {{ data_get($content, 'highlight', '৪-৫ ফোঁটা তেল নিয়ে ভালোভাবে ম্যাসাজ করুন') }}
@foreach($usageFeatures->take(3) as $feature)
{{ $feature }}
@endforeach
{{-- ================================================================ REVIEWS ================================================================= --}} @elseif($section->type === 'reviews') @if($reviewScreenshots->isNotEmpty())
@foreach($reviewScreenshots as $index => $image)
@endforeach
@endif {{-- ================================================================ ORDER ================================================================= --}} @elseif($section->type === 'order')

{{ data_get($content, 'title', 'অর্ডার ফর্ম') }}

{{ data_get($content, 'subtitle', 'আপনার অর্ডারটি প্লেস করতে, অনুগ্রহ করে নিচের তথ্য গুলো দিয়ে সহযোগিতা করুন।') }}

বিকাশে ১০০% টাকা ফেরত, নিশ্চিন্তে অর্ডার করুন
@csrf

Your Products

@foreach($productOptions as $optionIndex => $option)
{{ $option['name'] }}
{{ $option['name'] }} @if(filled($option['description'])) {{ \Illuminate\Support\Str::limit(strip_tags($option['description']), 60) }} @endif
1
@if($option['regular_price'] > $option['price']) {{ number_format($option['regular_price'], 0) }}৳ @endif {{ number_format($option['price'], 0) }}৳
@endforeach
{{-- Billing --}}

Billing details

{{ data_get($content, 'delivery_heading', 'ডেলিভারি এলাকা') }}

@if($landingPageFreeShipping) ফ্রি শিপিং @endif
@foreach($deliveryAreaList as $areaIndex => $area) @php $areaKey = data_get($area, 'key') ?? data_get($area, 'value') ?? data_get($area, 'code') ?? $areaIndex; $areaLabel = data_get($area, 'label') ?? data_get($area, 'name') ?? (string) $areaKey; @endphp @endforeach
{{-- Order Summary --}}

Your order

Product Subtotal
× {{ $product->name }}
{{ $productOptions->first()['name'] ?? $product->name }}
× 1
{{ number_format($initialPrice, 0) }}৳
Subtotal {{ number_format($initialPrice, 0) }}৳
Delivery Calculating...
Total {{ number_format($initialPrice, 0) }}৳
{{ data_get($content, 'payment_title', 'ক্যাশ অন ডেলিভারি (COD)') }}
{{ data_get($content, 'payment_text', 'পণ্য হাতে পেয়ে মূল্য পরিশোধ করবেন।') }}
{{-- ================================================================ FOOTER ================================================================= --}} @elseif($section->type === 'footer') @endif @endforeach
{{-- MOBILE FIXED ORDER BUTTON --}} @if(!($previewMode ?? false) && optional($orderSection)->is_enabled) এখনই অর্ডার করুন @endif {{-- WHATSAPP LIVE CHAT ICON (Always Animated) --}} @if(filled($whatsapp)) @endif {{-- IMAGE MODAL --}} {{-- TOAST --}} {{-- JS DATA --}}