Skip to content

Commit

Permalink
Merge pull request #15122 from snipe/fixes/15121_bulk_delete_and_restore
Browse files Browse the repository at this point in the history
Fixed #15121 - bulk delete restore logging
  • Loading branch information
snipe authored Jul 19, 2024
2 parents 8b05ef6 + 94619e3 commit 9ea38fb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public function edit(Request $request) : View | RedirectResponse
// This handles all of the pivot sorting below (versus the assets.* fields in the allowed_columns array)
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'assets.id';

$assets = Asset::with('assignedTo', 'location', 'model')->whereIn('assets.id', $asset_ids);
$assets = Asset::with('assignedTo', 'location', 'model')
->whereIn('assets.id', $asset_ids)
->withTrashed();

$assets = $assets->get();

Expand Down Expand Up @@ -483,12 +485,7 @@ public function destroy(Request $request) : RedirectResponse
if ($request->filled('ids')) {
$assets = Asset::find($request->get('ids'));
foreach ($assets as $asset) {
$update_array['deleted_at'] = date('Y-m-d H:i:s');
$update_array['assigned_to'] = null;

DB::table('assets')
->where('id', $asset->id)
->update($update_array);
$asset->delete();
} // endforeach

return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));
Expand Down

0 comments on commit 9ea38fb

Please sign in to comment.