Skip to content

Commit cbeda81

Browse files
committed
changed undeployable_assets query
1 parent bc235b1 commit cbeda81

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

app/Http/Controllers/Assets/BulkAssetsController.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,8 @@ public function edit(Request $request) : View | RedirectResponse
5353

5454
$asset_ids = $request->input('ids');
5555
if ($request->input('bulk_actions') === 'checkout') {
56-
$undeployable_assets = Asset::whereIn('id', $asset_ids)
57-
->whereHas('assetStatus', function ($query){
58-
$query->where('deployable', 0)
59-
->where('archived', 0)
60-
->where('pending', 0);
61-
})
62-
->get();
56+
$undeployable_assets = Asset::findMany($asset_ids)->filter(fn(Asset $asset) => !$asset->availableForCheckout());
57+
6358
if($undeployable_assets->count() > 0) {
6459
return redirect()->back()->with('error', trans_choice('admin/hardware/form.bulk_asset_undeployable', $undeployable_assets->count()));
6560
}

0 commit comments

Comments
 (0)