ldc-cocotte/app/Queries/Orders/GetFoCustomerPaginatedOrdersQuery.php
Jérémy Munsch 3b3997d547
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-27 09:58:44 +01:00

52 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Queries\Orders;
use App\Contracts\Query;
use App\Contracts\QueryInput;
use App\Dto\OrderDto;
use App\Models\Order;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\LengthAwarePaginator as ConcreteLengthAwarePaginator;
use SortDirection;
use Webmozart\Assert\Assert;
/**
* @implements \App\Contracts\Query<\App\Queries\Orders\GetFoCustomerPaginatedOrdersQueryInput, \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\OrderDto>>
*/
final readonly class GetFoCustomerPaginatedOrdersQuery implements Query
{
/**
* @param \App\Queries\Orders\GetFoCustomerPaginatedOrdersQueryInput $input
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<int, \App\Dto\OrderDto>
*/
#[\Override]
public function __invoke(QueryInput $input): LengthAwarePaginator
{
Assert::isInstanceOf($input, GetFoCustomerPaginatedOrdersQueryInput::class);
/** @var \Domain\Models\ValueObjects\Matricule|null $employeeMatricule */
$employeeMatricule = $input->customer->employee()->value('matricule');
if ($employeeMatricule === null) {
return new ConcreteLengthAwarePaginator(
items: [],
total: 0,
perPage: $input->pagination->pageSize()->value(),
currentPage: $input->pagination->pageNumber()->value(),
);
}
$paginator = Order::query()
->where('employee_matricule', $employeeMatricule->value)
->orderBy('id', SortDirection::Descending)
->paginate(
perPage: $input->pagination->pageSize()->value(),
page: $input->pagination->pageNumber()->value(),
);
return $paginator->through(fn (Order $order): OrderDto => OrderDto::fromModel($order));
}
}