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

Home Layout Manager

Left panel — available section templates  •  Middle — arrange sections on your home page  •  Right — live summary

@forelse(pages() as $page) {{ Str::limit($page->title, 14) }} @empty @endforelse Home Page New Page
{{-- ══ LEFT: Available Sections ══ --}}
Available Sections @if(isset($sections)) {{ $sections->count() }} templates @endif
@if(isset($sections) && $sections->count() > 0) @foreach($sections as $section) @php $s = json_decode($section->settings ?? '{}', true); $tc = $s['total_category'] ?? 0; $tw = $s['total_widgets'] ?? 0; $ta = $s['total_ads'] ?? 0; $ia = $s['is_ads_section'] ?? false; @endphp
@if(!empty($section->image)) {{ $section->display_name }} @endif @if($ia)
@if(isset($adv) && $adv->count() > 0) @else
No advertisements available.
@endif
@else
@if($tc > 0 && isset($categories))
    No categories selected yet
@endif
@if($tw > 0 && isset($widgets)) @endif @if($ta > 0 && isset($adv)) @endif @if(($tw > 0 && isset($widgets)) || ($ta > 0 && isset($adv)))
    No widgets or ads selected yet
@endif
@endif
@endforeach @else
No section templates available.
@endif
{{-- ══ MIDDLE: Active Layout ══ --}}
Home Page Layout Drag sections to reorder
@if(isset($layouts) && $layouts->count() > 0) @foreach($layouts as $layout) @php $ss = json_decode($layout->section->settings ?? '{}', true); $ls = json_decode($layout->settings ?? '{}', true); if (is_string($ls)) { $ls = json_decode($ls, true) ?? []; } $ia = $ss['is_ads_section'] ?? false; $tc = $ss['total_category'] ?? 0; $tw = $ss['total_widgets'] ?? 0; $ta = $ss['total_ads'] ?? 0; $ocid = $ls['assign_category'] ?? []; $oc = collect(); foreach ($ocid as $cid) { $cat = $layout->categories->firstWhere('id', $cid); if ($cat) $oc->push($cat); } $ien = $layout->status ? 1 : 0; $cn = $oc->pluck('name')->join(', '); @endphp
@if(!empty($layout->section->image)) {{ $layout->section->display_name }} @endif @if($ia) @php $sad = $ls['ads_id'] ?? null; @endphp
@if(isset($adv) && $adv->count() > 0) @else
No advertisements available.
@endif
@else
@if($tc > 0 && isset($categories))
    @forelse($oc as $o)
  • {{ $o->name }}
  • @empty @endforelse
@endif
@if($tw > 0 && isset($widgets)) @php $awids = $ls['assign_widgets'] ?? ($ls['Assign Widgets'] ?? []); $awc = collect(); foreach ($awids as $wid) { $w = $widgets->firstWhere('id', $wid); if ($w) $awc->push($w); } @endphp @endif @if($ta > 0 && isset($adv)) @php $aaids = $ls['assign_ads'] ?? ($ls['Assign Ads'] ?? []); $aac = collect(); foreach ($aaids as $aid) { $a = $adv->firstWhere('id', $aid); if ($a) $aac->push($a); } @endphp @endif @if(($tw > 0 && isset($widgets)) || ($ta > 0 && isset($adv))) @php $co = $ls['combined_order'] ?? []; if (empty($co)) { $wids2 = $ls['assign_widgets'] ?? ($ls['Assign Widgets'] ?? []); $aids2 = $ls['assign_ads'] ?? ($ls['Assign Ads'] ?? []); $co = []; foreach ($wids2 as $wid) $co[] = ['type' => 'widget', 'id' => $wid]; foreach ($aids2 as $aid) $co[] = ['type' => 'ads', 'id' => $aid]; } $ci = []; foreach ($co as $oi) { if ($oi['type'] === 'widget') { $w = $widgets->firstWhere('id', $oi['id']); if ($w) $ci[] = ['id' => $w->id, 'title' => $w->title, 'type' => 'widget']; } elseif ($oi['type'] === 'ads') { $a = $adv->firstWhere('id', $oi['id']); if ($a) $ci[] = ['id' => $a->id, 'title' => $a->title ?? 'Ad #'.$a->id, 'type' => 'ads']; } } @endphp
    @forelse($ci as $item)
  • {{ $item['title'] }} @if($item['type'] === 'widget') Widget @else Ad @endif
  • @empty
  • No widgets or ads selected yet
  • @endforelse
@endif
@endif
@endforeach @else

Drag a section from the left panel,
or click the + button to add it here

@endif
{{-- ══ RIGHT: Live Summary ══ --}}
Summary
{{-- Big stat cards --}} @php $totalCat = 0; $totalWid = 0; $totalAds = 0; $activeCount = 0; $disabledCount = 0; $totalSec = isset($layouts) ? $layouts->count() : 0; if(isset($layouts)){ foreach($layouts as $l){ $ls2 = json_decode($l->settings ?? '{}', true); if(is_string($ls2)) $ls2 = json_decode($ls2, true) ?? []; $ss2 = json_decode($l->section->settings ?? '{}', true); $ia2 = $ss2['is_ads_section'] ?? false; $totalCat += count($ls2['assign_category'] ?? []); $totalWid += count($ls2['assign_widgets'] ?? ($ls2['Assign Widgets'] ?? [])); if($ia2){ $totalAds += ($ls2['ads_id'] ? 1 : 0); } else { $totalAds += count($ls2['assign_ads'] ?? ($ls2['Assign Ads'] ?? [])); } if($l->status) $activeCount++; else $disabledCount++; } } @endphp
Total Sections
{{ $totalSec }}
Sections on home page
Categories
{{ $totalCat }}
Assigned across all sections
Widgets
{{ $totalWid }}
Widgets in use
Advertisements
{{ $totalAds }}
Ad slots filled

{{-- Active / Disabled --}}
Section Status
{{ $activeCount }}
Active
{{ $disabledCount }}
Disabled

{{-- Per-section breakdown --}}
Sections in Layout
@if(isset($layouts) && $layouts->count() > 0) @foreach($layouts as $idx => $layout) @php $ss3 = json_decode($layout->section->settings ?? '{}', true); $ls3 = json_decode($layout->settings ?? '{}', true); if(is_string($ls3)) $ls3 = json_decode($ls3, true) ?? []; $ia3 = $ss3['is_ads_section'] ?? false; $tc3 = $ss3['total_category'] ?? 0; $tw3 = $ss3['total_widgets'] ?? 0; $ta3 = $ss3['total_ads'] ?? 0; $cc3 = count($ls3['assign_category'] ?? []); $wc3 = count($ls3['assign_widgets'] ?? ($ls3['Assign Widgets'] ?? [])); $ac3 = $ia3 ? ($ls3['ads_id'] ? 1 : 0) : count($ls3['assign_ads'] ?? ($ls3['Assign Ads'] ?? [])); @endphp
{{ $idx + 1 }} {{ $layout->section->display_name ?? 'Section' }} @if($ia3) @else @if($tc3 > 0) {{ $cc3 }}/{{ $tc3 }} @endif @if($tw3 > 0) {{ $wc3 }}/{{ $tw3 }} @endif @if($ta3 > 0) {{ $ac3 }}/{{ $ta3 }} @endif @endif
@endforeach @else
No sections yet
@endif
{{-- .lm-grid --}} {{-- Action bar --}}
Unsaved changes
@endsection @section('js') @endsection