- 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
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Lib\Helpers;
|
|
|
|
use Illuminate\Http\Request as HttpRequest;
|
|
use Shared\Pagination\PageNumber;
|
|
use Shared\Pagination\PageSize;
|
|
use Shared\Pagination\Pagination;
|
|
use Uri\Rfc3986\Uri;
|
|
|
|
final class RequestHelper
|
|
{
|
|
private function __construct()
|
|
{
|
|
// Static class
|
|
}
|
|
|
|
public static function pagination(HttpRequest $request, int $defaultPageSize = 25): Pagination
|
|
{
|
|
if ($request->has('offset') || $request->has('limit')) {
|
|
return Pagination::ofOffsetAndLimit(
|
|
$request->integer('offset', 0),
|
|
$request->integer('limit', $defaultPageSize)
|
|
);
|
|
}
|
|
|
|
$pageSize = $request->integer(
|
|
'pageSize',
|
|
$request->integer('per_page', $request->integer('pagination', $defaultPageSize))
|
|
);
|
|
|
|
return Pagination::ofPage(
|
|
new PageNumber($request->integer('page', 1)),
|
|
new PageSize($pageSize)
|
|
);
|
|
}
|
|
|
|
public static function toUri(HttpRequest $request): Uri
|
|
{
|
|
return new Uri($request->url());
|
|
}
|
|
|
|
public static function toFullUri(HttpRequest $request): Uri
|
|
{
|
|
return new Uri($request->fullUrl());
|
|
}
|
|
}
|