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
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Settings;
|
|
|
|
|
|
|
|
|
|
use App\Actions\Settings\UpdateSettingsInput;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Infrastructure\Adapters\Services\AppAdminAuthService;
|
|
|
|
|
|
|
|
|
|
class UpdateSettingsRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly AppAdminAuthService $authService
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->authService->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[\Override]
|
|
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
2026-10-02 12:14:48 +02:00
|
|
|
$rawSites = $this->input('employee_sites');
|
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
|
|
|
|
|
|
|
|
if (is_string($rawSites)) {
|
|
|
|
|
$split = preg_split('/[\s,]+/', $rawSites) ?: [];
|
|
|
|
|
$filtered = array_filter(
|
|
|
|
|
array_map(static fn (string $s): string => strtoupper(trim($s)), $split),
|
|
|
|
|
static fn (string $s): bool => $s !== ''
|
|
|
|
|
);
|
|
|
|
|
$sites = array_values(array_unique($filtered));
|
|
|
|
|
} elseif (is_array($rawSites)) {
|
|
|
|
|
$filtered = array_filter(
|
|
|
|
|
array_map(static fn (mixed $s): string => is_string($s) ? strtoupper(trim($s)) : '', $rawSites),
|
|
|
|
|
static fn (string $s): bool => $s !== ''
|
|
|
|
|
);
|
|
|
|
|
$sites = array_values(array_unique($filtered));
|
|
|
|
|
} else {
|
|
|
|
|
$sites = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->merge([
|
|
|
|
|
'employee_sites' => $sites,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, mixed>
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'employee_sites' => ['present', 'array'],
|
|
|
|
|
'employee_sites.*' => ['string', 'regex:/^[A-Z]{2,}$/'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[\Override]
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'employee_sites' => 'Sites des salariés',
|
|
|
|
|
'employee_sites.*' => 'Code de site des salariés',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
#[\Override]
|
|
|
|
|
public function messages(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'employee_sites.*.regex' => 'Chaque code de site doit être composé d\'au moins 2 lettres majuscules (ex: PA, NA, LY).',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toUpdateSettingsInput(): UpdateSettingsInput
|
|
|
|
|
{
|
|
|
|
|
/** @var array<int, string> $sites */
|
|
|
|
|
$sites = $this->validated('employee_sites', []);
|
|
|
|
|
|
|
|
|
|
return new UpdateSettingsInput(
|
|
|
|
|
employeeSites: array_map(
|
|
|
|
|
static fn (string $site): ShopperSiteCode => new ShopperSiteCode($site),
|
|
|
|
|
$sites
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|