Deploy to Production (witstore.wende.it) / deploy (push) Successful in 7s
- E-Mail-Templates: DB-gespeicherte HTML-Templates mit {{placeholder}}-System,
Admin-UI zum Bearbeiten von Betreff und Body, alle 4 Mailables aktualisiert
- Seiten-Layouts: 4 Layouts für CMS-Seiten (Standard, Sidebar, Volle Breite, Landing),
Layout-Auswahl im Admin-Formular
- Shop-Themes: 5 Farbthemen via CSS-Variablen, Picker in Einstellungen
- Deployment: EmailTemplateSeeder wird automatisch beim Deploy ausgeführt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
2.4 KiB
PHP
72 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Page;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PageController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$pages = Page::orderBy('type')->orderBy('title')->get();
|
|
return view('admin.pages.index', compact('pages'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('admin.pages.form');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$data = $this->validated($request);
|
|
Page::create($data);
|
|
return redirect()->route('admin.pages.index')->with('success', 'Seite erstellt.');
|
|
}
|
|
|
|
public function edit(Page $page)
|
|
{
|
|
return view('admin.pages.form', compact('page'));
|
|
}
|
|
|
|
public function update(Request $request, Page $page)
|
|
{
|
|
$data = $this->validated($request, $page);
|
|
$page->update($data);
|
|
return redirect()->route('admin.pages.index')->with('success', 'Seite aktualisiert.');
|
|
}
|
|
|
|
public function destroy(Page $page)
|
|
{
|
|
$page->delete();
|
|
return redirect()->route('admin.pages.index')->with('success', 'Seite gelöscht.');
|
|
}
|
|
|
|
private function validated(Request $request, ?Page $page = null): array
|
|
{
|
|
$data = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'slug' => 'nullable|string|max:255',
|
|
'type' => 'required|in:static,blog,faq',
|
|
'content' => 'nullable|string',
|
|
'meta_title' => 'nullable|string|max:255',
|
|
'meta_description' => 'nullable|string|max:500',
|
|
'published' => 'boolean',
|
|
'published_at' => 'nullable|date',
|
|
'show_in_footer' => 'boolean',
|
|
'show_in_nav' => 'boolean',
|
|
'nav_sort' => 'integer|min:0',
|
|
'layout' => 'nullable|in:default,sidebar,full,landing',
|
|
]);
|
|
$data['slug'] = $data['slug'] ? Str::slug($data['slug']) : Str::slug($data['title']);
|
|
$data['published'] = $request->boolean('published');
|
|
$data['show_in_footer'] = $request->boolean('show_in_footer');
|
|
$data['show_in_nav'] = $request->boolean('show_in_nav');
|
|
$data['layout'] = $request->input('layout', 'default');
|
|
return $data;
|
|
}
|
|
}
|