Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
89b35ac480
commit
2035c46edd
130 files changed
+18519
-50
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
public function home(): View
|
||||
{
|
||||
return $this->render(Page::query()->where('path', '/')->firstOrFail(), preview: false);
|
||||
}
|
||||
|
||||
public function show(string $path): View
|
||||
{
|
||||
return $this->render(Page::query()->where('path', '/'.$path)->firstOrFail(), preview: false);
|
||||
}
|
||||
|
||||
public function preview(PageRevision $revision): View
|
||||
{
|
||||
$page = $revision->page;
|
||||
Gate::authorize('view', $page);
|
||||
|
||||
return $this->render($page, preview: true, revision: $revision);
|
||||
}
|
||||
|
||||
public function sitemap(): Response
|
||||
{
|
||||
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get();
|
||||
|
||||
return response()
|
||||
->view('public.sitemap', ['pages' => $pages])
|
||||
->header('Content-Type', 'application/xml');
|
||||
}
|
||||
|
||||
private function render(Page $page, bool $preview, ?PageRevision $revision = null): View
|
||||
{
|
||||
$revision ??= $page->publishedRevision;
|
||||
abort_if($revision === null, 404);
|
||||
|
||||
$heading = collect($revision->blocks)->firstWhere('type', 'heading');
|
||||
|
||||
return view('public.page', [
|
||||
'page' => $page,
|
||||
'revision' => $revision,
|
||||
'preview' => $preview,
|
||||
'documentTitle' => $revision->seo_title ?: ($heading['heading'] ?? config('app.name')),
|
||||
'documentDescription' => $revision->seo_description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user