77 lines
1.8 KiB
PHP
77 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Fo\Pages;
|
|
|
|
use App\Contracts\Executor;
|
|
use App\Contracts\QueryInputEmpty;
|
|
use App\Dto\PageDto;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Queries\Faqs\GetFaqsQuery;
|
|
use App\Queries\Pages\GetPageQuery;
|
|
use App\Queries\Pages\GetPageQueryInput;
|
|
use Domain\Enums\StaticPageSlug;
|
|
use Domain\Models\ValueObjects\Slug;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
class PageController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly Executor $executor,
|
|
private readonly GetPageQuery $getPageQuery,
|
|
) {
|
|
}
|
|
|
|
public function legalNotice(): View
|
|
{
|
|
$page = $this->getPageBySlug(StaticPageSlug::LEGALS);
|
|
|
|
return view('fo.pages.legal-notice', compact(
|
|
'page'
|
|
));
|
|
}
|
|
|
|
public function terms(): View
|
|
{
|
|
$page = $this->getPageBySlug(StaticPageSlug::TERMS);
|
|
|
|
return view('fo.pages.terms', compact(
|
|
'page'
|
|
));
|
|
}
|
|
|
|
public function privacy(): View
|
|
{
|
|
$page = $this->getPageBySlug(StaticPageSlug::PRIVACY);
|
|
|
|
return view('fo.pages.privacy', compact(
|
|
'page'
|
|
));
|
|
}
|
|
|
|
public function faq(GetFaqsQuery $getFaqsQuery): View
|
|
{
|
|
$page = $this->getPageBySlug(StaticPageSlug::FAQ);
|
|
$faqs = $this->executor->execute(
|
|
$getFaqsQuery,
|
|
new QueryInputEmpty()
|
|
);
|
|
|
|
return view('fo.pages.faq', compact(
|
|
'faqs',
|
|
'page'
|
|
));
|
|
}
|
|
|
|
private function getPageBySlug(StaticPageSlug $pageSlug): PageDto
|
|
{
|
|
$slug = new Slug(strval($pageSlug->value()));
|
|
$pageSlugInput = new GetPageQueryInput($slug);
|
|
|
|
return $this->executor->execute(
|
|
$this->getPageQuery,
|
|
$pageSlugInput
|
|
);
|
|
}
|
|
}
|