Files
laraundfelix/app/Http/Controllers/ThemeController.php
T
LarsandCursor 8cd382c357
Deploy Test / test (push) Successful in 15s
Deploy Test / deploy (push) Successful in 22s
Veröffentliche fachliche Säulen als Themenbereiche der Website.
Dieselbe Liste trägt die öffentliche Seite. Medien bleiben privat, Seiten können mehreren Säulen zugeordnet sein.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 11:46:48 +01:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Domain\Catalog\Pillar;
use Illuminate\View\View;
class ThemeController extends Controller
{
public function index(): View
{
return view('public.themes.index', [
'themes' => Pillar::query()->published()->get(),
]);
}
public function show(string $slug): View
{
$theme = Pillar::query()->published()->where('slug', $slug)->firstOrFail();
$pages = $theme->pages()
->whereNotNull('published_revision_id')
->with('publishedRevision')
->orderBy('path')
->get();
return view('public.themes.show', [
'theme' => $theme,
'pages' => $pages,
'documentDescription' => $this->description($theme),
]);
}
private function description(Pillar $theme): string
{
$summary = trim((string) $theme->public_summary);
$summary = preg_replace('/\s+/', ' ', $summary) ?? '';
if (mb_strlen($summary) <= 160) {
return $summary;
}
return rtrim(mb_substr($summary, 0, 157)).'…';
}
}