Intégration fonctionnalites V1

This commit is contained in:
bastien
2026-07-04 22:30:18 +02:00
parent 55a558b536
commit 10ee859602
54 changed files with 4802 additions and 1018 deletions
@@ -21,18 +21,60 @@ class PricingPageController extends Controller
->with(['establishment:id,name', 'machine:id,uuid,name']);
$this->scopeEstablishmentQuery($query);
$this->applyEstablishmentFilter($request, $query);
if ($request->filled('machine_type')) {
$query->where('machine_type', $request->string('machine_type'));
}
if ($request->filled('day_type')) {
$query->where('day_type', $request->string('day_type'));
}
if ($request->has('is_active') && $request->string('is_active')->toString() !== '') {
$query->where('is_active', $request->boolean('is_active'));
}
if ($request->filled('search')) {
$search = $request->string('search');
$query->where('label', 'like', "%{$search}%");
}
$rules = $query
->orderBy('priority')
->orderBy('slot_start')
->get()
->map(fn (PricingRule $rule) => $this->formatRule($rule));
->tap(fn ($builder) => $this->applySort($request, $builder, [
'establishment' => fn ($builder, string $direction) => $this->sortByRelatedEstablishment(
$builder,
'pricing_rules',
'establishment_id',
$direction,
),
'slot_start' => 'slot_start',
'machine_type' => 'machine_type',
'price' => 'price',
'priority' => 'priority',
'is_active' => 'is_active',
], 'priority', 'asc'))
->paginate($this->supervisorListPerPage($request))
->withQueryString()
->through(fn (PricingRule $rule) => $this->formatRule($rule));
return Inertia::render('Supervisor/Pricing/Index', [
'rules' => $rules,
'establishments' => $this->establishmentOptions(),
'machineTypes' => $this->machineTypeOptions(),
'dayTypes' => $this->dayTypeOptions(),
'filters' => [
'establishment_id' => $request->filled('establishment_id') ? (int) $request->input('establishment_id') : null,
'machine_type' => $request->string('machine_type')->toString() ?: null,
'day_type' => $request->string('day_type')->toString() ?: null,
'is_active' => $request->has('is_active') && $request->string('is_active')->toString() !== ''
? ($request->boolean('is_active') ? '1' : '0')
: null,
'search' => $request->string('search')->toString() ?: null,
'sort' => $request->string('sort')->toString() ?: 'priority',
'direction' => $request->string('direction')->toString() === 'desc' ? 'desc' : 'asc',
'per_page' => $this->supervisorListPerPage($request),
],
]);
}
@@ -134,22 +176,6 @@ class PricingPageController extends Controller
];
}
/**
* @return array<int, array{id: int, name: string}>
*/
private function establishmentOptions(): array
{
$supervisor = $this->supervisor();
return Establishment::query()
->where('organization_id', $supervisor->organization_id)
->when($supervisor->establishment_id, fn ($q) => $q->where('id', $supervisor->establishment_id))
->orderBy('name')
->get(['id', 'name'])
->map(fn (Establishment $e) => ['id' => $e->id, 'name' => $e->name])
->all();
}
/**
* @return array<string, string>
*/