@extends('admin.layouts.master') @section('title', 'Home Layout Manager') @section('content')

Home Layout Manager

@forelse(pages() as $page) {{ Str::limit($page->title, 15) }} @empty
No pages available
@endforelse Home Page New Page
Available Sections
@if (isset($sections) && $sections->count() > 0) @foreach ($sections as $section) @php $settings = json_decode($section->settings ?? '{}', true); $totalCategory = $settings['total_category'] ?? 0; $totalWidgets = $settings['total_widgets'] ?? 0; $totalAds = $settings['total_ads'] ?? 0; $isAdsSection = $settings['is_ads_section'] ?? false; @endphp
@if (!empty($section->image)) {{ $section->display_name }} @endif @if ($isAdsSection)
@if (isset($adv) && $adv->count() > 0) @else
No advertisements available.
@endif
@else
@if ($totalCategory > 0 && isset($categories))
    No categories selected
@endif
@if ($totalWidgets > 0 && isset($widgets)) @endif @if ($totalAds > 0 && isset($adv)) @endif @if (($totalWidgets > 0 && isset($widgets)) || ($totalAds > 0 && isset($adv)))
    No widgets or ads selected
@endif
@endif
@endforeach @else
No sections available.
@endif
Home Page Sections
@if (isset($layouts) && $layouts->count() > 0) @foreach ($layouts as $layout) @php $sectionSettings = json_decode($layout->section->settings ?? '{}', true); $layoutSettings = json_decode($layout->settings ?? '{}', true); if (is_string($layoutSettings)) { $layoutSettings = json_decode($layoutSettings, true) ?? []; } $isAdsSection = $sectionSettings['is_ads_section'] ?? false; $totalCategory = $sectionSettings['total_category'] ?? 0; $totalWidgets = $sectionSettings['total_widgets'] ?? 0; $totalAds = $sectionSettings['total_ads'] ?? 0; $orderedCategoryIds = $layoutSettings['assign_category'] ?? []; $orderedCategories = collect(); foreach ($orderedCategoryIds as $catId) { $category = $layout->categories->firstWhere('id', $catId); if ($category) { $orderedCategories->push($category); } } $isEnabled = $layout->status ? 1 : 0; @endphp
@if (!empty($layout->section->image)) {{ $layout->section->display_name }} @endif @if ($isAdsSection) @php $selectedAdId = $layoutSettings['ads_id'] ?? null; @endphp
@if (isset($adv) && $adv->count() > 0) @else
No advertisements available.
@endif
@else
@if ($totalCategory > 0 && isset($categories))
    @forelse ($orderedCategories as $orderedCat)
  • {{ $orderedCat->name }}
  • @empty @endforelse
@endif
@if ($totalWidgets > 0 && isset($widgets)) @php $assignedWidgetIds = $layoutSettings['assign_widgets'] ?? ($layoutSettings['Assign Widgets'] ?? []); $assignedWidgets = collect(); foreach ($assignedWidgetIds as $wId) { $widget = $widgets->firstWhere('id', $wId); if ($widget) { $assignedWidgets->push($widget); } } @endphp @endif @if ($totalAds > 0 && isset($adv)) @php $assignedAdIds = $layoutSettings['assign_ads'] ?? ($layoutSettings['Assign Ads'] ?? []); $assignedAds = collect(); foreach ($assignedAdIds as $aId) { $ad = $adv->firstWhere('id', $aId); if ($ad) { $assignedAds->push($ad); } } @endphp @endif @if (($totalWidgets > 0 && isset($widgets)) || ($totalAds > 0 && isset($adv)))
    @php $combinedOrder = $layoutSettings['combined_order'] ?? []; if (empty($combinedOrder)) { $widgetIds = $layoutSettings['assign_widgets'] ?? ($layoutSettings['Assign Widgets'] ?? []); $adIds = $layoutSettings['assign_ads'] ?? ($layoutSettings['Assign Ads'] ?? []); $combinedOrder = []; foreach ($widgetIds as $wId) { $combinedOrder[] = ['type' => 'widget', 'id' => $wId]; } foreach ($adIds as $aId) { $combinedOrder[] = ['type' => 'ads', 'id' => $aId]; } } $combinedItems = []; foreach ($combinedOrder as $orderItem) { if ($orderItem['type'] == 'widget') { $widget = $widgets->firstWhere('id', $orderItem['id']); if ($widget) { $combinedItems[] = ['id' => $widget->id, 'title' => $widget->title, 'type' => 'widget']; } } elseif ($orderItem['type'] == 'ads') { $ad = $adv->firstWhere('id', $orderItem['id']); if ($ad) { $combinedItems[] = ['id' => $ad->id, 'title' => $ad->title ?? 'Ad #' . $ad->id, 'type' => 'ads']; } } } @endphp @forelse ($combinedItems as $item)
  • {{ $item['title'] }} @if ($item['type'] == 'widget') Widget @else Ad @endif
  • @empty
  • No widgets or ads selected
  • @endforelse
@endif
@endif
@endforeach @else

Drag sections from the left panel to build your home page layout

@endif
@endsection