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>
45 lines
1.1 KiB
PHP
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)).'…';
|
|
}
|
|
}
|