diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php index e4e8a4871..96951bdf8 100644 --- a/app/Http/Transformers/CompaniesTransformer.php +++ b/app/Http/Transformers/CompaniesTransformer.php @@ -38,7 +38,7 @@ class CompaniesTransformer $permissions_array['available_actions'] = [ 'update' => Gate::allows('update', Company::class) ? true : false, - 'delete' => (Gate::allows('delete', Category::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false, + 'delete' => (Gate::allows('delete', Company::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false, ]; $array += $permissions_array; diff --git a/app/Policies/CompanyPolicy.php b/app/Policies/CompanyPolicy.php new file mode 100644 index 000000000..7efcc99f3 --- /dev/null +++ b/app/Policies/CompanyPolicy.php @@ -0,0 +1,13 @@ + SupplierPolicy::class, User::class => UserPolicy::class, Manufacturer::class => ManufacturerPolicy::class, + Company::class => CompanyPolicy::class, ]; /** @@ -132,6 +135,7 @@ class AuthServiceProvider extends ServiceProvider || $user->can('view', \App\Models\Location::class) || $user->can('view', \App\Models\Company::class) || $user->can('view', \App\Models\Manufacturer::class) + || $user->can('view', \App\Models\Company::class) || $user->can('view', \App\Models\Depreciation::class); }); } diff --git a/config/permissions.php b/config/permissions.php index 0337916c1..531c05d05 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -521,6 +521,33 @@ return array( ), ), + 'Companies' => array( + array( + 'permission' => 'companies.view', + 'label' => 'View ', + 'note' => '', + 'display' => true, + ), + array( + 'permission' => 'companies.create', + 'label' => 'Create ', + 'note' => '', + 'display' => true, + ), + array( + 'permission' => 'companies.edit', + 'label' => 'Edit ', + 'note' => '', + 'display' => true, + ), + array( + 'permission' => 'companies.delete', + 'label' => 'Delete ', + 'note' => '', + 'display' => true, + ), + ), +