'', 'showForm' => false, 'editingId' => null, 'editLocale' => 'de', 'activeTab' => 'basic', 'slug' => '', 'projectTitle' => '', 'location' => '', 'status' => '', 'launch_date' => '', 'price_from_aed' => '', 'currency' => 'AED', 'image' => '', 'is_published' => true, 'order' => 0, 'highlights' => [''], 'quick_facts' => [['icon' => 'home-modern', 'label' => '', 'value' => '']], 'investTitle' => '', 'investText' => '', 'investViews' => [''], 'galleryItems' => [''], 'locTitle' => '', 'locMapUrl' => '', 'locPoints' => [''], 'contactTitle' => '', 'contactSubtitle' => '', 'contactOptions' => [['key' => '', 'value' => '']], 'trustTitle' => '', 'trustIntro' => '', 'trustColumns' => [ ['icon' => 'heroicon-o-lock-closed', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-building-library', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-chart-bar', 'title' => '', 'text' => ''], ], 'trustCtaUrl' => '', 'trustCtaLabel' => '', 'furnitureTitle' => '', 'furnitureText' => '', 'furnitureButtonText' => '', 'furnitureButtonLink' => '', ]); on(['media-selected' => function ($mediaId, $url, $field) { $media = $mediaId ? \FluxCms\Core\Models\CmsMedia::find($mediaId) : null; if (! $media) { return; } if ($field === 'project_image') { $this->image = $media->filename; } if (str_starts_with($field, 'gallery_')) { $idx = (int) str_replace('gallery_', '', $field); if (isset($this->galleryItems[$idx])) { $this->galleryItems[$idx] = $media->filename; } } }]); $projects = computed( fn () => CmsProject::query() ->when($this->search, fn ($q) => $q->where('slug', 'like', "%{$this->search}%")) ->ordered() ->get(), ); $resetForm = function () { $this->editingId = null; $this->activeTab = 'basic'; $this->slug = ''; $this->projectTitle = ''; $this->location = ''; $this->status = ''; $this->launch_date = ''; $this->price_from_aed = ''; $this->currency = 'AED'; $this->image = ''; $this->is_published = true; $this->order = 0; $this->highlights = ['']; $this->quick_facts = [['icon' => 'home-modern', 'label' => '', 'value' => '']]; $this->investTitle = ''; $this->investText = ''; $this->investViews = ['']; $this->galleryItems = ['']; $this->locTitle = ''; $this->locMapUrl = ''; $this->locPoints = ['']; $this->contactTitle = ''; $this->contactSubtitle = ''; $this->contactOptions = [['key' => '', 'value' => '']]; $this->trustTitle = ''; $this->trustIntro = ''; $this->trustColumns = [ ['icon' => 'heroicon-o-lock-closed', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-building-library', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-chart-bar', 'title' => '', 'text' => ''], ]; $this->trustCtaUrl = ''; $this->trustCtaLabel = ''; $this->furnitureTitle = ''; $this->furnitureText = ''; $this->furnitureButtonText = ''; $this->furnitureButtonLink = ''; }; $loadProjectIntoForm = function (CmsProject $project, string $locale) { $this->slug = $project->slug; $this->image = $project->image ?? ''; $this->status = $project->status ?? ''; $this->launch_date = $project->launch_date?->format('Y-m-d') ?? ''; $this->price_from_aed = $project->price_from_aed ?? ''; $this->currency = $project->currency ?? 'AED'; $this->is_published = $project->is_published; $this->order = $project->order ?? 0; $this->projectTitle = $project->getTranslation('title', $locale) ?? ''; $this->location = $project->getTranslation('location', $locale) ?? ''; $hl = $project->getTranslation('highlights', $locale); $this->highlights = is_array($hl) && count($hl) > 0 ? $hl : ['']; $this->quick_facts = is_array($project->quick_facts) && count($project->quick_facts) > 0 ? $project->quick_facts : [['icon' => 'home-modern', 'label' => '', 'value' => '']]; $ic = $project->getTranslation('investment_case', $locale); $this->investTitle = $ic['title'] ?? ''; $this->investText = $ic['text'] ?? ''; $this->investViews = is_array($ic['views'] ?? null) && count($ic['views']) > 0 ? $ic['views'] : ['']; $this->galleryItems = is_array($project->gallery) && count($project->gallery) > 0 ? $project->gallery : ['']; $li = $project->getTranslation('location_info', $locale); $this->locTitle = $li['title'] ?? ''; $this->locMapUrl = $li['map_url'] ?? ''; $this->locPoints = is_array($li['points'] ?? null) && count($li['points']) > 0 ? $li['points'] : ['']; $ct = $project->getTranslation('contact', $locale); $this->contactTitle = $ct['title'] ?? ''; $this->contactSubtitle = $ct['subtitle'] ?? ''; $opts = $ct['options'] ?? []; $this->contactOptions = count($opts) > 0 ? collect($opts)->map(fn ($v, $k) => ['key' => $k, 'value' => $v])->values()->toArray() : [['key' => '', 'value' => '']]; $it = $project->getTranslation('investor_trust', $locale) ?? []; $this->trustTitle = $it['title'] ?? ''; $this->trustIntro = $it['intro'] ?? ''; $trustCols = $it['columns'] ?? []; $this->trustColumns = is_array($trustCols) && count($trustCols) > 0 ? $trustCols : [ ['icon' => 'heroicon-o-lock-closed', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-building-library', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-chart-bar', 'title' => '', 'text' => ''], ]; $this->trustCtaUrl = $it['cta_url'] ?? ''; $this->trustCtaLabel = $it['cta_label'] ?? ''; $fb = $project->getTranslation('furniture_benefit', $locale) ?? []; $this->furnitureTitle = $fb['title'] ?? ''; $this->furnitureText = $fb['text'] ?? ''; $this->furnitureButtonText = $fb['button_text'] ?? ''; $this->furnitureButtonLink = $fb['button_link'] ?? ''; }; $openCreate = function () { $this->resetForm(); $this->showForm = true; }; $openEdit = function (int $id) { $project = CmsProject::find($id); if (! $project) { return; } $this->editingId = $id; $this->activeTab = 'basic'; $this->loadProjectIntoForm($project, $this->editLocale); $this->showForm = true; }; $duplicateProject = function (int $id) { $project = CmsProject::find($id); if (! $project) { return; } $this->editingId = null; $this->activeTab = 'basic'; $this->loadProjectIntoForm($project, $this->editLocale); $this->slug = $project->slug . '-kopie-' . Str::random(4); $this->showForm = true; Flux::toast(heading: 'Dupliziert', text: 'Projekt wurde als Kopie geladen. Bitte Slug anpassen und speichern.'); }; $switchLocale = function (string $locale) { $this->editLocale = $locale; if ($this->editingId) { $project = CmsProject::find($this->editingId); if ($project) { $this->projectTitle = $project->getTranslation('title', $locale) ?? ''; $this->location = $project->getTranslation('location', $locale) ?? ''; $hl = $project->getTranslation('highlights', $locale); $this->highlights = is_array($hl) && count($hl) > 0 ? $hl : ['']; $ic = $project->getTranslation('investment_case', $locale); $this->investTitle = $ic['title'] ?? ''; $this->investText = $ic['text'] ?? ''; $this->investViews = is_array($ic['views'] ?? null) && count($ic['views']) > 0 ? $ic['views'] : ['']; $li = $project->getTranslation('location_info', $locale); $this->locTitle = $li['title'] ?? ''; $this->locMapUrl = $li['map_url'] ?? ''; $this->locPoints = is_array($li['points'] ?? null) && count($li['points']) > 0 ? $li['points'] : ['']; $ct = $project->getTranslation('contact', $locale); $this->contactTitle = $ct['title'] ?? ''; $this->contactSubtitle = $ct['subtitle'] ?? ''; $opts = $ct['options'] ?? []; $this->contactOptions = count($opts) > 0 ? collect($opts)->map(fn ($v, $k) => ['key' => $k, 'value' => $v])->values()->toArray() : [['key' => '', 'value' => '']]; $it = $project->getTranslation('investor_trust', $locale) ?? []; $this->trustTitle = $it['title'] ?? ''; $this->trustIntro = $it['intro'] ?? ''; $trustCols = $it['columns'] ?? []; $this->trustColumns = is_array($trustCols) && count($trustCols) > 0 ? $trustCols : [ ['icon' => 'heroicon-o-lock-closed', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-building-library', 'title' => '', 'text' => ''], ['icon' => 'heroicon-o-chart-bar', 'title' => '', 'text' => ''], ]; $this->trustCtaUrl = $it['cta_url'] ?? ''; $this->trustCtaLabel = $it['cta_label'] ?? ''; $fb = $project->getTranslation('furniture_benefit', $locale) ?? []; $this->furnitureTitle = $fb['title'] ?? ''; $this->furnitureText = $fb['text'] ?? ''; $this->furnitureButtonText = $fb['button_text'] ?? ''; $this->furnitureButtonLink = $fb['button_link'] ?? ''; } } }; $addHighlight = fn () => $this->highlights[] = ''; $removeHighlight = function (int $i) { unset($this->highlights[$i]); $this->highlights = array_values($this->highlights); }; $addQuickFact = fn () => $this->quick_facts[] = ['icon' => 'home-modern', 'label' => '', 'value' => '']; $removeQuickFact = function (int $i) { unset($this->quick_facts[$i]); $this->quick_facts = array_values($this->quick_facts); }; $addInvestView = fn () => $this->investViews[] = ''; $removeInvestView = function (int $i) { unset($this->investViews[$i]); $this->investViews = array_values($this->investViews); }; $addGalleryItem = fn () => $this->galleryItems[] = ''; $removeGalleryItem = function (int $i) { unset($this->galleryItems[$i]); $this->galleryItems = array_values($this->galleryItems); }; $addLocPoint = fn () => $this->locPoints[] = ''; $removeLocPoint = function (int $i) { unset($this->locPoints[$i]); $this->locPoints = array_values($this->locPoints); }; $addContactOption = fn () => $this->contactOptions[] = ['key' => '', 'value' => '']; $removeContactOption = function (int $i) { unset($this->contactOptions[$i]); $this->contactOptions = array_values($this->contactOptions); }; $addTrustColumn = fn () => $this->trustColumns[] = ['icon' => 'heroicon-o-lock-closed', 'title' => '', 'text' => '']; $removeTrustColumn = function (int $i) { unset($this->trustColumns[$i]); $this->trustColumns = array_values($this->trustColumns); }; $save = function () { $validated = validator([ 'slug' => $this->slug, 'projectTitle' => $this->projectTitle, 'location' => $this->location, 'status' => $this->status, 'launch_date' => $this->launch_date, 'price_from_aed' => $this->price_from_aed, 'currency' => $this->currency, 'image' => $this->image, 'is_published' => $this->is_published, 'order' => $this->order, ], [ 'slug' => 'required|string|max:255', 'projectTitle' => 'required|string|max:500', 'location' => 'nullable|string|max:500', 'status' => 'nullable|string|max:100', 'launch_date' => 'nullable|date', 'price_from_aed' => 'nullable|integer|min:0', 'currency' => 'nullable|string|max:10', 'image' => 'nullable|string|max:500', 'is_published' => 'boolean', 'order' => 'integer|min:0', ])->validate(); $project = $this->editingId ? CmsProject::findOrFail($this->editingId) : CmsProject::query()->make(); $project->slug = $validated['slug']; $project->setTranslation('title', $this->editLocale, $validated['projectTitle']); $project->setTranslation('location', $this->editLocale, $validated['location'] ?? ''); $project->status = $validated['status'] ?? null; $project->launch_date = $validated['launch_date'] ?: null; $project->price_from_aed = $validated['price_from_aed'] ?: null; $project->currency = $validated['currency'] ?? 'AED'; $project->image = $validated['image'] ?? null; $project->is_published = $validated['is_published']; $project->order = $validated['order']; $project->setTranslation('highlights', $this->editLocale, array_values(array_filter($this->highlights, fn ($h) => trim($h) !== ''))); $project->quick_facts = collect($this->quick_facts) ->filter(fn ($f) => ! empty($f['label']) || ! empty($f['value'])) ->values() ->toArray(); $project->setTranslation('investment_case', $this->editLocale, [ 'title' => $this->investTitle, 'text' => $this->investText, 'views' => array_values(array_filter($this->investViews, fn ($v) => trim($v) !== '')), ]); $project->gallery = array_values(array_filter($this->galleryItems, fn ($g) => trim($g) !== '')); $project->setTranslation('location_info', $this->editLocale, [ 'title' => $this->locTitle, 'map_url' => $this->locMapUrl, 'points' => array_values(array_filter($this->locPoints, fn ($p) => trim($p) !== '')), ]); $opts = []; foreach ($this->contactOptions as $opt) { if ($opt['value'] !== '') { $opts[$opt['key']] = $opt['value']; } } $project->setTranslation('contact', $this->editLocale, [ 'title' => $this->contactTitle, 'subtitle' => $this->contactSubtitle, 'options' => $opts, ]); $trustCols = collect($this->trustColumns) ->filter(fn ($c) => ! empty(trim($c['title'] ?? '')) || ! empty(trim($c['text'] ?? ''))) ->values() ->toArray(); $project->setTranslation('investor_trust', $this->editLocale, [ 'title' => $this->trustTitle, 'intro' => $this->trustIntro, 'columns' => $trustCols, 'cta_url' => $this->trustCtaUrl, 'cta_label' => $this->trustCtaLabel, ]); $project->setTranslation('furniture_benefit', $this->editLocale, [ 'title' => $this->furnitureTitle, 'text' => $this->furnitureText, 'button_text' => $this->furnitureButtonText, 'button_link' => $this->furnitureButtonLink, ]); $project->save(); $this->showForm = false; $this->editingId = null; Flux::toast(variant: 'success', heading: 'Gespeichert', text: $project->slug . ' wurde erfolgreich gespeichert.'); }; $deleteProject = function (int $id) { $project = CmsProject::find($id); if (! $project) { return; } $slug = $project->slug; $project->delete(); Flux::toast(variant: 'success', heading: 'Gelöscht', text: "{$slug} wurde entfernt."); }; $cancelForm = function () { $this->showForm = false; $this->editingId = null; }; $setActiveTab = function (string $tab): void { $this->activeTab = $tab; }; ?>
Projekte (Immobilien) Neues Projekt
@if ($showForm)
{{ $editingId ? 'Projekt bearbeiten' : 'Neues Projekt' }}
@foreach (config('flux-cms.locales', ['de' => 'DE', 'en' => 'EN']) as $code => $label) {{ strtoupper($code) }} @endforeach
{{-- Explizite Tab-Steuerung: zuverlässiger als nur wire:model auf ui-tabs (Livewire-Sync) --}}
Grunddaten Quick Facts Investment Case Galerie Location Kontakt Trust & Möbel
{{-- TAB: Grunddaten --}} @if ($activeTab === 'basic')
@if ($image)
@endif
Highlights ({{ strtoupper($editLocale) }})
@foreach ($highlights as $i => $hl)
@if (count($highlights) > 1) @endif
@endforeach
Highlight
@endif {{-- TAB: Quick Facts --}} @if ($activeTab === 'facts')
@foreach ($quick_facts as $i => $fact)
Haus Fläche Gebäude Person Preis Kalender Standort @if (count($quick_facts) > 1) @endif
@endforeach Quick Fact
@endif {{-- TAB: Investment Case --}} @if ($activeTab === 'invest')
@foreach ($investViews as $i => $view)
@if (count($investViews) > 1) @endif
@endforeach
View
@endif {{-- TAB: Galerie --}} @if ($activeTab === 'gallery')
@foreach ($galleryItems as $i => $img)
@if ($img)
@endif
@if (count($galleryItems) > 1) @endif
@endforeach Bild hinzufügen
@endif {{-- TAB: Location --}} @if ($activeTab === 'location')
@foreach ($locPoints as $i => $point)
@if (count($locPoints) > 1) @endif
@endforeach
Punkt
@endif {{-- TAB: Kontakt --}} @if ($activeTab === 'contact')
@foreach ($contactOptions as $i => $opt)
@if (count($contactOptions) > 1) @endif
@endforeach
Option
@endif {{-- TAB: Trust-Block & Möbel-Vorteil (Detailseite) --}} @if ($activeTab === 'trust_synergy')
Trust-Block: Investorenschutz ({{ strtoupper($editLocale) }})
@foreach ($trustColumns as $ti => $tc)
Schloss (Escrow) Gebäude / DLD Diagramm Schild Sparkles @if (count($trustColumns) > 1) @endif
@endforeach
Spalte hinzufügen
Möbel-Vorteil / Synergie ({{ strtoupper($editLocale) }})
@endif
Speichern Abbrechen
@endif {{-- Projektliste --}}
@forelse ($this->projects as $project)
@if ($project->image)
@else
@endif
{{ $project->title }} @if ($project->is_published) Live @else Entwurf @endif
{{ $project->location }} @if ($project->status) · {{ $project->status }} @endif @if ($project->getFormattedPrice()) · {{ $project->getFormattedPrice() }} @endif
@empty
Keine Projekte Erstelle das erste Projekt mit dem Button oben.
@endforelse