ldc-boutique-cnc-sable/app/Casts/ShopperServiceCodeCast.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

37 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Casts;
use Domain\Models\ValueObjects\ShopperServiceCode;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
/** @implements CastsAttributes<ShopperServiceCode, ShopperServiceCode|string> */
class ShopperServiceCodeCast implements CastsAttributes
{
/** @param array<string, mixed> $attributes */
public function get(Model $model, string $key, mixed $value, array $attributes): ShopperServiceCode
{
if ($value === null || ! is_string($value)) {
throw new \UnexpectedValueException('ShopperServiceCode must be a string.');
}
return new ShopperServiceCode($value);
}
/** @param array<string, mixed> $attributes */
public function set(Model $model, string $key, mixed $value, array $attributes): string
{
if (is_string($value)) {
$value = new ShopperServiceCode($value);
}
if (! $value instanceof ShopperServiceCode) {
throw new \UnexpectedValueException('The given value is not an instance of ShopperServiceCode.');
}
return $value->value;
}
}