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

114 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Bo;
use App\Actions\Ranges\CreateRange;
use App\Actions\Ranges\DeleteRange;
use App\Actions\Ranges\DeleteRangeInput;
use App\Actions\Ranges\UpdateRange;
use App\Contracts\Executor;
use App\Dto\RangeDto;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Ranges\StoreRangeRequest;
use App\Http\Requests\Bo\Ranges\UpdateRangeRequest;
use App\Lib\Helpers\RequestHelper;
use App\Models\Range;
use App\Queries\Ranges\GetPaginatedRangesQuery;
use App\Queries\Ranges\GetPaginatedRangesQueryInput;
use App\Traits\Controllers\ChangesModelOrder;
use App\Traits\Controllers\TogglesModelStatus;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class RangesController extends Controller
{
use ChangesModelOrder;
use TogglesModelStatus;
public function __construct(
private readonly Executor $executor,
) {
}
public function index(Request $request, GetPaginatedRangesQuery $query): View
{
$this->authorize('viewAny', Range::class);
$pagination = RequestHelper::pagination($request);
$ranges = $this->executor->execute(
$query,
new GetPaginatedRangesQueryInput(
pagination: $pagination,
)
);
return view('bo.ranges.index', compact('ranges'));
}
public function create(): View
{
$this->authorize('create', Range::class);
return view('bo.ranges.create');
}
public function store(StoreRangeRequest $request, CreateRange $action): RedirectResponse
{
$this->authorize('create', Range::class);
$range = $this->executor->execute(
$action,
$request->toCreateRangeInput(),
);
return to_route('bo.ranges.edit', $range)
->with('success', trans('crud.messages.has_been_created', [
'model' => Str::ucfirst(trans_choice('models.classes.ranges', 1)),
]));
}
public function edit(Range $range): View
{
$this->authorize('update', $range);
$range = RangeDto::fromModel($range);
return view('bo.ranges.edit', compact('range'));
}
public function update(UpdateRangeRequest $request, Range $range, UpdateRange $action): RedirectResponse
{
$this->authorize('update', $range);
$this->executor->execute(
$action,
$request->toUpdateRangeInput($range),
);
return to_route('bo.ranges.edit', $range)
->with('success', trans('crud.messages.has_been_updated', [
'model' => Str::ucfirst(trans_choice('models.classes.ranges', 1)),
]));
}
public function destroy(Range $range, DeleteRange $action): RedirectResponse
{
$this->authorize('delete', $range);
$this->executor->execute(
$action,
new DeleteRangeInput(range: $range),
);
return to_route('bo.ranges.index')
->with('warning', trans(
'crud.messages.has_been_deleted',
['model' => Str::ucfirst(trans_choice('models.classes.ranges', 1))]
));
}
}