mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Improved - disallow delete if not elgible in UI
This commit is contained in:
parent
528630a8d3
commit
1ef44721f5
|
@ -22,10 +22,21 @@ class CompaniesController extends Controller
|
|||
{
|
||||
$this->authorize('view', Company::class);
|
||||
|
||||
$allowed_columns = ['id','name'];
|
||||
$allowed_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'users_count',
|
||||
'assets_count',
|
||||
'licenses_count',
|
||||
'accessories_count',
|
||||
'consumables_count',
|
||||
'components_count',
|
||||
];
|
||||
|
||||
$companies = Company::withCount('assets','licenses','accessories','consumables','components','users')
|
||||
->withCount('users')->withCount('users')->withCount('assets')
|
||||
->withCount('users')->withCount('assets')
|
||||
->withCount('licenses')->withCount('accessories')
|
||||
->withCount('consumables')->withCount('components');
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class DepartmentsTransformer
|
|||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Department::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Department::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
|
|
@ -57,7 +57,7 @@ class LocationsTransformer
|
|||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', Location::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Location::class) ? true : false,
|
||||
'delete' => (Gate::allows('delete', Department::class) && ($location->assigned_assets_count==0) && ($location->assets_count==0) && ($location->users_count==0) && ($location->deleted_at=='')) ? true : false,
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
|
Loading…
Reference in a new issue