This commit is contained in:
elvira committed 2026-10-26 16:06:55 +02:00
1 parent 50ec0eebf2
commit 1e4da2c8cc
73 files changed
+763 -43

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use App\Models\StoicFaq;
use App\Models\StoicFaqSection;
use App\Models\StoicPage;
use App\Services\Stoic;
use App\Support\StorePlaceholders;
use Illuminate\Support\Str;
use Illuminate\View\View;
/**
* FAQ page: pages/faq.md lists the sections, each section lists its FAQs
* (both Stoic relations, so the order is the editor's). Answers are markdown
* and can use the same store placeholders as the legal pages.
*/
class FaqController extends Controller
{
public function index(string $locale, StorePlaceholders $placeholders): View
{
$page = StoicPage::localized('faq');
if (! $page) {
abort(404);
}
$sections = Stoic::localizedRelation(StoicFaqSection::class, $page->sections, 'faq-sections')
->map(function (StoicFaqSection $section) use ($placeholders) {
$section->items = Stoic::localizedRelation(StoicFaq::class, $section->faqs, 'faqs')
->map(fn (StoicFaq $faq) => $faq->forceFill([
'answer' => Str::markdown($placeholders->fill($faq->content ?? '')),
]));
return $section;
})
->filter(fn (StoicFaqSection $section) => $section->items->isNotEmpty())
->values();
return view('faq', [
'page' => $page,
'sections' => $sections,
]);
}
}