mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
fix tests
This commit is contained in:
parent
a534b488b2
commit
eaacf29d57
|
@ -529,22 +529,27 @@ class BulkAssetsController extends Controller
|
||||||
if ($request->session()->has('bulk_back_url')) {
|
if ($request->session()->has('bulk_back_url')) {
|
||||||
$bulk_back_url = $request->session()->pull('bulk_back_url');
|
$bulk_back_url = $request->session()->pull('bulk_back_url');
|
||||||
}
|
}
|
||||||
$assetIds = $request->get('ids');
|
$assetIds = $request->get('ids') ?? [];
|
||||||
|
|
||||||
|
if(empty($assetIds)) {
|
||||||
|
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));
|
||||||
|
}
|
||||||
|
|
||||||
$assignedAssets = Asset::whereIn('id', $assetIds)->whereNotNull('assigned_to')->get();
|
$assignedAssets = Asset::whereIn('id', $assetIds)->whereNotNull('assigned_to')->get();
|
||||||
|
|
||||||
if($assignedAssets->isNotEmpty()) {
|
if($assignedAssets->isNotEmpty()) {
|
||||||
//if assets are checked out, return a list of asset tags that would need to be checked in first.
|
//if assets are checked out, return a list of asset tags that would need to be checked in first.
|
||||||
$assetTags = $assignedAssets->pluck('asset_tag')->implode(', ');
|
$assetTags = $assignedAssets->pluck('asset_tag')->implode(', ');
|
||||||
return redirect()->route('hardware.index')->with('error', trans_choice('admin/hardware/message.delete.assigned_to_error', $assignedAssets->count(), ['asset_tag' => $assetTags] ));
|
return redirect()->route($bulk_back_url)->with('error', trans_choice('admin/hardware/message.delete.assigned_to_error', $assignedAssets->count(), ['asset_tag' => $assetTags] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assetIds) {
|
foreach (Asset::wherein('id', $assetIds)->get() as $asset) {
|
||||||
Asset::wherein('id', $assetIds)->delete();
|
$asset->delete();
|
||||||
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));
|
||||||
// no values given, nothing to update
|
// no values given, nothing to update
|
||||||
|
|
||||||
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue