Files
InvoiceShelf/database/seeders/UsersTableSeeder.php
Darko Gjorgjijoski 0ce88ab817 Remove app/Space folder and extract model business logic into services
Relocate all 14 files from the catch-all app/Space namespace into proper
locations: data providers to Support/Formatters, installation utilities to
Services/Installation, PDF utils to Services/Pdf, module/update classes to
Services/Module and Services/Update, SiteApi trait to Traits, and helpers
to Support.

Extract ~1,400 lines of business logic from 8 fat models (Invoice, Payment,
Estimate, RecurringInvoice, Company, Customer, Expense, User) into 9 new
service classes with constructor injection. Controllers now depend on
services instead of calling static model methods. Shared item/tax creation
logic consolidated into DocumentItemService.
2026-04-03 15:37:22 +02:00

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\Installation\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('super admin');
Setting::setSetting('profile_complete', 0);
// Set version.
InstallUtils::setCurrentVersion();
}
}