ldc-boutique-cnc-sable/app/Http/Controllers/Bo/EmployeesController.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

42 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Jobs\FetchAndUpsertArcadiaEmployees;
use App\Services\FlashMessageService;
use Illuminate\Bus\Dispatcher;
use Illuminate\Bus\UniqueLock;
use Illuminate\Contracts\Cache\Repository as CacheRepository;
use Illuminate\Http\RedirectResponse;
class EmployeesController extends Controller
{
public function __construct(
private readonly FlashMessageService $flashMessageService,
private readonly Dispatcher $dispatcher,
private readonly CacheRepository $cacheRepository,
) {
}
public function launchSyncJob(FetchAndUpsertArcadiaEmployees $syncJob): RedirectResponse
{
$this->authorize('dispatchArcadiaRefreshJob', FetchAndUpsertArcadiaEmployees::class);
$uniqueLock = new UniqueLock($this->cacheRepository);
if (! $uniqueLock->acquire($syncJob)) {
$this->flashMessageService->warning(__('An employee sync is already in progress.'));
return to_route('bo.dashboard');
}
// $this->dispatcher->dispatchAfterResponse($syncJob);
$this->dispatcher->dispatch($syncJob);
$this->flashMessageService->success(__('The employee sync job has been dispatched'));
return to_route('bo.dashboard');
}
}