Intégration fonctionnalites V1
This commit is contained in:
@@ -19,6 +19,8 @@ class BookingPageController extends Controller
|
||||
->with(['user:id,first_name,last_name,email', 'machine:id,uuid,name,establishment_id', 'machine.establishment:id,name']);
|
||||
|
||||
$this->scopeMachineRelationQuery($query);
|
||||
$this->applyEstablishmentFilter($request, $query, 'machine');
|
||||
$this->applyUserSearchFilter($request, $query);
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->string('status'));
|
||||
@@ -29,8 +31,14 @@ class BookingPageController extends Controller
|
||||
}
|
||||
|
||||
$bookings = $query
|
||||
->orderByDesc('slot_start')
|
||||
->paginate(20)
|
||||
->tap(fn ($builder) => $this->applySort($request, $builder, [
|
||||
'slot_start' => 'bookings.slot_start',
|
||||
'user' => fn ($builder, string $direction) => $this->sortByRelatedUser($builder, 'bookings', 'user_id', $direction),
|
||||
'machine' => fn ($builder, string $direction) => $this->sortByRelatedMachine($builder, 'bookings', $direction),
|
||||
'status' => 'bookings.status',
|
||||
'booking_fee' => 'bookings.booking_fee',
|
||||
], 'slot_start', 'desc'))
|
||||
->paginate($this->supervisorListPerPage($request))
|
||||
->withQueryString()
|
||||
->through(fn (Booking $booking) => [
|
||||
'uuid' => $booking->uuid,
|
||||
@@ -54,9 +62,15 @@ class BookingPageController extends Controller
|
||||
|
||||
return Inertia::render('Supervisor/Bookings/Index', [
|
||||
'bookings' => $bookings,
|
||||
'establishments' => $this->establishmentOptions(),
|
||||
'filters' => [
|
||||
'establishment_id' => $request->filled('establishment_id') ? (int) $request->input('establishment_id') : null,
|
||||
'user' => $request->string('user')->toString() ?: null,
|
||||
'status' => $request->string('status')->toString() ?: null,
|
||||
'date' => $request->string('date')->toString() ?: null,
|
||||
'sort' => $request->string('sort')->toString() ?: 'slot_start',
|
||||
'direction' => $request->string('direction')->toString() === 'asc' ? 'asc' : 'desc',
|
||||
'per_page' => $this->supervisorListPerPage($request),
|
||||
],
|
||||
'statusOptions' => $this->statusOptions(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user