mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
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.
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\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();
|
|
}
|
|
}
|