Reapply deleted code

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-19 17:26:21 +01:00
parent 5c3180ffa0
commit 2dcae780c0

View file

@ -190,8 +190,13 @@ class AssetMaintenancesController extends Controller
{
$this->authorize('update', Asset::class);
// Check if the asset maintenance exists
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);
if (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot delete a maintenance for that asset'));
}
$assetMaintenance->delete();
return response()->json(Helper::formatStandardApiResponse('success', $assetMaintenance, trans('admin/asset_maintenances/message.delete.success')));