ldc-cocotte/app/Cqs/Queries/PickupExceptions/GetPaginatedPickupExceptionsQuery.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

45 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Cqs\Queries\PickupExceptions;
use App\Contracts\Query;
use App\Contracts\QueryInput;
use App\Dto\PickupExceptionDto;
use App\Models\PickupException;
use App\Services\DataTableService;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Webmozart\Assert\Assert;
/**
* @implements \App\Contracts\Query<
* \App\Cqs\Queries\PickupExceptions\GetPaginatedPickupExceptionsQueryInput,
* \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\PickupExceptionDto>
* >
*/
final readonly class GetPaginatedPickupExceptionsQuery implements Query
{
public function __construct(
private DataTableService $dataTable,
) {
}
/**
* @param \App\Cqs\Queries\PickupExceptions\GetPaginatedPickupExceptionsQueryInput $input
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\PickupExceptionDto>
*/
#[\Override]
public function __invoke(QueryInput $input): LengthAwarePaginator
{
Assert::isInstanceOf($input, GetPaginatedPickupExceptionsQueryInput::class);
$query = PickupException::query();
$this->dataTable->sortQuery(PickupException::class, $query);
$paginator = $this->dataTable->paginateQuery($query, $input->pagination);
return $paginator->through(fn (PickupException $pe): PickupExceptionDto => PickupExceptionDto::fromModel($pe));
}
}