mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Check that the asset is not deleted
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
1dfa1da0ee
commit
8a4c90ade8
|
@ -148,15 +148,16 @@ class AssetMaintenancesController extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit($assetMaintenanceId = null)
|
public function edit($assetMaintenanceId = null)
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', Asset::class);
|
||||||
|
// Check if the asset maintenance exists
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
// Check if the asset maintenance exists
|
// Check if the asset maintenance exists
|
||||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||||
// Redirect to the improvement management page
|
// Redirect to the asset maintenance management page
|
||||||
return redirect()->route('maintenances.index')
|
return redirect()->route('maintenances.index')->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
} elseif ((!$assetMaintenance->asset) || ($assetMaintenance->asset->deleted_at!='')) {
|
||||||
} elseif (! $assetMaintenance->asset) {
|
// Redirect to the asset maintenance management page
|
||||||
return redirect()->route('maintenances.index')
|
return redirect()->route('maintenances.index')->with('error', 'asset does not exist');
|
||||||
->with('error', 'The asset associated with this maintenance does not exist.');
|
|
||||||
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||||
return static::getInsufficientPermissionsRedirect();
|
return static::getInsufficientPermissionsRedirect();
|
||||||
}
|
}
|
||||||
|
@ -192,8 +193,10 @@ class AssetMaintenancesController extends Controller
|
||||||
// Check if the asset maintenance exists
|
// Check if the asset maintenance exists
|
||||||
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
|
||||||
// Redirect to the asset maintenance management page
|
// Redirect to the asset maintenance management page
|
||||||
return redirect()->route('maintenances.index')
|
return redirect()->route('maintenances.index')->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
} elseif ((!$assetMaintenance->asset) || ($assetMaintenance->asset->deleted_at!='')) {
|
||||||
|
// Redirect to the asset maintenance management page
|
||||||
|
return redirect()->route('maintenances.index')->with('error', 'asset does not exist');
|
||||||
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||||
return static::getInsufficientPermissionsRedirect();
|
return static::getInsufficientPermissionsRedirect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue