Eliminate Company\CompaniesController, introduce owner role

Redistribute methods:
- show() -> BootstrapController::currentCompany()
- store(), destroy(), userCompanies() -> Admin\CompaniesController
- transferOwnership() -> CompanySettingsController

Security fix: introduce 'owner' role for company-level admin, distinct
from 'super admin' which is now global platform admin only.
- CompanyService::setupRoles() creates 'owner' role per company
- Company creation assigns scoped 'owner' role instead of global 'super admin'
- Seeders updated to assign 'owner'

Migration renames all existing company-scoped 'super admin' roles to
'owner' and ensures every company owner has the role assigned.
This commit is contained in:
Darko Gjorgjijoski
2026-04-03 22:33:56 +02:00
parent 5912995164
commit 00d5abae5f
10 changed files with 151 additions and 111 deletions

View File

@@ -26,14 +26,14 @@ class CompanyService
{
BouncerFacade::scope()->to($company->id);
$superAdmin = BouncerFacade::role()->firstOrCreate([
'name' => 'super admin',
'title' => 'Super Admin',
$owner = BouncerFacade::role()->firstOrCreate([
'name' => 'owner',
'title' => 'Owner',
'scope' => $company->id,
]);
foreach (config('abilities.abilities') as $ability) {
BouncerFacade::allow($superAdmin)->to($ability['ability'], $ability['model']);
BouncerFacade::allow($owner)->to($ability['ability'], $ability['model']);
}
}