@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(); /* |-------------------------------------------------------------------------- | Footer |-------------------------------------------------------------------------- */ $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, '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
{{ data_get($content, 'subtitle', 'আপনার অর্ডারটি প্লেস করতে, অনুগ্রহ করে নিচের তথ্য গুলো দিয়ে সহযোগিতা করুন।') }}