2026-09-30 12:08:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\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;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-10-03 10:50:06 +02:00
|
|
|
* @implements \App\Contracts\Query<
|
|
|
|
|
* \App\Queries\PickupExceptions\GetPaginatedPickupExceptionsQueryInput,
|
|
|
|
|
* \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\PickupExceptionDto>
|
|
|
|
|
* >
|
2026-09-30 12:08:22 +02:00
|
|
|
*/
|
|
|
|
|
final readonly class GetPaginatedPickupExceptionsQuery implements Query
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private DataTableService $dataTable,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param \App\Queries\PickupExceptions\GetPaginatedPickupExceptionsQueryInput $input
|
2026-09-30 17:57:20 +02:00
|
|
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\PickupExceptionDto>
|
2026-09-30 12:08:22 +02:00
|
|
|
*/
|
|
|
|
|
#[\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));
|
|
|
|
|
}
|
|
|
|
|
}
|