3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 19:45:51 +00:00

Basic sanity checking on some of the API controllers

This commit is contained in:
snipe
2017-03-11 08:03:16 -08:00
parent 9027bd1d9d
commit 2a4bf65883
6 changed files with 104 additions and 6 deletions

View File

@ -148,6 +148,11 @@ class AssetModelsController extends Controller
$this->authorize('delete', AssetModel::class);
$assetmodel = AssetModel::findOrFail($id);
$this->authorize('delete', $assetmodel);
if ($assetmodel->assets()->count() > 0) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/models/message.assoc_users')));
}
$assetmodel->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/assetmodels/message.delete.success')));