2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Casts;
|
|
|
|
|
|
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
|
|
|
use Domain\Models\ValueObjects\OrderEmployee;
|
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-01 17:26:30 +02:00
|
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
|
|
|
|
|
/** @implements CastsAttributes<OrderEmployee|null,OrderEmployee|null> */
|
|
|
|
|
class OrderEmployeeCast implements CastsAttributes
|
|
|
|
|
{
|
|
|
|
|
/** @param array<string, mixed> $attributes */
|
|
|
|
|
public function get(Model $model, string $key, mixed $value, array $attributes): ?OrderEmployee
|
|
|
|
|
{
|
|
|
|
|
if (is_null($value)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! is_string($value)) {
|
2026-10-02 10:53:21 +02:00
|
|
|
throw new \InvalidArgumentException('The value must be a string.');
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = Arr::wrap(json_decode($value, true));
|
|
|
|
|
|
|
|
|
|
return new OrderEmployee(
|
|
|
|
|
matricule: new Matricule(Arr::string($data, 'matricule')),
|
|
|
|
|
firstname: Arr::string($data, 'firstname'),
|
|
|
|
|
lastname: Arr::string($data, 'lastname'),
|
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-01 17:26:30 +02:00
|
|
|
facility: new ShopperEstablishmentCode(Arr::string($data, 'facility')),
|
|
|
|
|
site: new ShopperSiteCode(Arr::string($data, 'site')),
|
|
|
|
|
service: new ShopperServiceCode(Arr::string($data, 'service')),
|
2026-06-14 21:32:07 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @param array<string, mixed> $attributes */
|
|
|
|
|
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
|
|
|
|
|
{
|
|
|
|
|
if ($value === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! $value instanceof OrderEmployee) {
|
2026-10-02 10:53:21 +02:00
|
|
|
throw new \InvalidArgumentException('The given value is not an instance of OrderEmployee.');
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return json_encode([
|
|
|
|
|
'matricule' => $value->matricule->value,
|
|
|
|
|
'firstname' => $value->firstname,
|
|
|
|
|
'lastname' => $value->lastname,
|
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-01 17:26:30 +02:00
|
|
|
'facility' => $value->facility->value,
|
|
|
|
|
'site' => $value->site->value,
|
|
|
|
|
'service' => $value->service->value,
|
2026-06-14 21:32:07 +02:00
|
|
|
], JSON_THROW_ON_ERROR);
|
|
|
|
|
}
|
|
|
|
|
}
|