@extends('layouts.app')
@section('title', 'Website CMS')
@section('nav_website', 'bg-teal-50 text-teal-700 font-semibold')
@section('content')
{{-- Header --}}
Website Content
Manage what guests see on the public-facing website.
@if(session('success'))
{{ session('success') }}
@endif
@if($errors->any())
{{ $errors->first() }}
@endif
{{-- Maintenance Mode Toggle --}}
Website Maintenance Mode
@if($maintenanceOn)
ON — Guests see maintenance page
@else
LIVE
@endif
{{ $maintenanceOn
? 'Public website is hidden. Logged-in staff can still browse normally.'
: 'Public website is visible to all visitors.' }}
{{-- Tabs --}}
@php
$u = auth()->user();
$tabAreas = [
'homepage' => 'content', 'about' => 'content', 'contact' => 'content', 'social' => 'content',
'gallery' => 'content', 'rooms' => 'content', 'policies' => 'content', 'appearance' => 'content',
'booking' => 'booking', 'payment' => 'booking', 'promo' => 'booking',
'seo' => 'seo',
];
$tabLabels = [
'homepage' => 'Homepage', 'about' => 'About', 'contact' => 'Contact', 'social' => 'Social & Chat',
'gallery' => 'Gallery', 'rooms' => 'Room Photos', 'appearance' => 'Appearance', 'booking' => 'Booking Settings',
'payment' => 'How to Pay', 'promo' => 'Promo Bar', 'seo' => 'SEO', 'policies' => 'Policies',
];
$firstTab = collect($tabLabels)->keys()->first(fn ($k) => $u->canWebsite($tabAreas[$k])) ?? 'homepage';
@endphp
@foreach($tabLabels as $key => $label)
@if($u->canWebsite($tabAreas[$key]))
@endif
@endforeach
{{-- ── HOMEPAGE ─────────────────────────────────── --}}
{{-- ── ABOUT ─────────────────────────────────── --}}
{{-- ── CONTACT ─────────────────────────────────── --}}
{{-- ── SOCIAL & CHAT ───────────────────────────── --}}
{{-- ── GALLERY ─────────────────────────────────── --}}
{{-- Upload form --}}
{{-- Gallery grid --}}
@if($galleryPhotos->count())
Drag photos to reorder — the first is used as the gallery cover.
@foreach($galleryPhotos as $photo)
 }})
@if($photo->caption)
{{ $photo->caption }}
@endif
@endforeach
@else
No gallery photos yet. Upload one above.
@endif
{{-- ── ROOM PHOTOS ─────────────────────────────── --}}
@foreach($roomTypes as $roomType)
@php
$typeRoomNos = \App\Models\Room::where('type', $roomType)->pluck('no')->all();
$typePhotos = collect($typeRoomNos)->flatMap(fn($no) => $roomPhotos->get($no, collect())->all());
$firstRoomNo = $typeRoomNos[0] ?? null;
@endphp
{{ $roomType }}
{{ $typePhotos->count() }} photo{{ $typePhotos->count() !== 1 ? 's' : '' }}
{{-- Upload for first room of this type --}}
@if($firstRoomNo)
@endif
{{-- Photos grid --}}
@if($typePhotos->count())
@foreach($typePhotos as $photo)
@endforeach
@else
No photos yet for this room type.
@endif
@endforeach
{{-- ── BOOKING SETTINGS ─────────────────────────── --}}
{{-- ── HOW TO PAY ──────────────────────────────── --}}
{{-- ── PROMO BAR ───────────────────────────────── --}}
{{-- ── SEO ─────────────────────────────────── --}}
{{-- ── POLICIES ────────────────────────────────── --}}
{{-- ── APPEARANCE ──────────────────────────────── --}}
{{-- /x-data tabs --}}
{{-- Unsaved-changes guard: per-tab dirty tracking + beforeunload + cross-form save warning --}}
{{-- Drag-to-reorder for gallery & room photos (persists sort_order; first = cover) --}}