Intégration fonctionnalites V1
This commit is contained in:
@@ -19,6 +19,8 @@ class WashPageController 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,15 @@ class WashPageController extends Controller
|
||||
}
|
||||
|
||||
$washes = $query
|
||||
->orderByDesc('started_at')
|
||||
->paginate(20)
|
||||
->tap(fn ($builder) => $this->applySort($request, $builder, [
|
||||
'started_at' => 'washes.started_at',
|
||||
'user' => fn ($builder, string $direction) => $this->sortByRelatedUser($builder, 'washes', 'user_id', $direction),
|
||||
'machine' => fn ($builder, string $direction) => $this->sortByRelatedMachine($builder, 'washes', $direction),
|
||||
'status' => 'washes.status',
|
||||
'duration_minutes' => 'washes.duration_minutes',
|
||||
'cost' => 'washes.cost',
|
||||
], 'started_at', 'desc'))
|
||||
->paginate($this->supervisorListPerPage($request))
|
||||
->withQueryString()
|
||||
->through(fn (Wash $wash) => [
|
||||
'uuid' => $wash->uuid,
|
||||
@@ -56,9 +65,15 @@ class WashPageController extends Controller
|
||||
|
||||
return Inertia::render('Supervisor/Washes/Index', [
|
||||
'washes' => $washes,
|
||||
'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() ?: 'started_at',
|
||||
'direction' => $request->string('direction')->toString() === 'asc' ? 'asc' : 'desc',
|
||||
'per_page' => $this->supervisorListPerPage($request),
|
||||
],
|
||||
'statusOptions' => $this->statusOptions(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user