added catch for no assets selected

This commit is contained in:
slong753 2023-03-30 13:52:29 -05:00
parent b84eaaf61a
commit 382d849ee1

View file

@ -334,10 +334,14 @@ class BulkAssetsController extends Controller
}
public function restore(Request $request) {
$assetIds = $request->get('ids');
foreach ($assetIds as $key => $assetId) {
$asset = Asset::withTrashed()->find($assetId);
$asset->restore();
}
return redirect()->route('hardware.index')->with('success', 'Assets Restored');
if (empty($assetIds)) {
return redirect()->route('hardware.index')->with('error', 'No Assets Selected');
} else {
foreach ($assetIds as $key => $assetId) {
$asset = Asset::withTrashed()->find($assetId);
$asset->restore();
}
return redirect()->route('hardware.index')->with('success', 'Assets Restored');
}
}
}