mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
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.
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Facades\Hashids;
|
|
use App\Models\Company;
|
|
use App\Models\Setting;
|
|
use App\Models\User;
|
|
use App\Services\CompanyService;
|
|
use App\Services\Setup\InstallUtils;
|
|
use Illuminate\Database\Seeder;
|
|
use Silber\Bouncer\BouncerFacade;
|
|
|
|
class UsersTableSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$user = User::create([
|
|
'email' => 'admin@invoiceshelf.com',
|
|
'name' => 'Jane Doe',
|
|
'role' => 'super admin',
|
|
'password' => 'invoiceshelf@123',
|
|
]);
|
|
|
|
$company = Company::create([
|
|
'name' => 'xyz',
|
|
'owner_id' => $user->id,
|
|
'slug' => 'xyz',
|
|
]);
|
|
|
|
$company->unique_hash = Hashids::connection(Company::class)->encode($company->id);
|
|
$company->save();
|
|
app(CompanyService::class)->setupDefaults($company);
|
|
$user->companies()->attach($company->id);
|
|
BouncerFacade::scope()->to($company->id);
|
|
|
|
$user->assign('owner');
|
|
|
|
Setting::setSetting('profile_complete', 0);
|
|
// Set version.
|
|
InstallUtils::setCurrentVersion();
|
|
}
|
|
}
|