2026-09-29 16:59:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-10 14:28:00 +01:00
|
|
|
namespace App\Cqs\Queries\Pages;
|
2026-09-29 16:59:07 +02:00
|
|
|
|
|
|
|
|
use App\Contracts\Query;
|
|
|
|
|
use App\Contracts\QueryInput;
|
|
|
|
|
use App\Dto\PageDto;
|
|
|
|
|
use App\Models\Page;
|
|
|
|
|
use Webmozart\Assert\Assert;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-11-10 14:28:00 +01:00
|
|
|
* @implements \App\Contracts\Query<\App\Cqs\Queries\Pages\GetPageQueryInput, \App\Dto\PageDto>
|
2026-09-29 16:59:07 +02:00
|
|
|
*/
|
|
|
|
|
final readonly class GetPageQuery implements Query
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(QueryInput $input): PageDto
|
|
|
|
|
{
|
|
|
|
|
Assert::isAOf($input, GetPageQueryInput::class);
|
|
|
|
|
|
|
|
|
|
$page = Page::query()
|
|
|
|
|
->where('slug', $input->name->value)
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
|
|
|
|
|
return PageDto::fromModel($page);
|
|
|
|
|
}
|
|
|
|
|
}
|