36 lines
960 B
PHP
36 lines
960 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Role;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class SystemTenantSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$system = Tenant::firstOrCreate(
|
|
['type' => 'system'],
|
|
['name' => 'System', 'active' => true]
|
|
);
|
|
|
|
$admin = \App\Models\User::withoutGlobalScopes()->firstOrCreate(
|
|
['email' => 'admin@lernschiff.com'],
|
|
[
|
|
'name' => 'Platform Admin',
|
|
'tenant_id' => $system->id,
|
|
'password' => Hash::make('password'),
|
|
]
|
|
);
|
|
|
|
$role = Role::where('name', 'platform-admin')->first();
|
|
DB::table('role_user')->updateOrInsert(
|
|
['user_id' => $admin->id],
|
|
['role_id' => $role->id, 'created_at' => now(), 'updated_at' => now()]
|
|
);
|
|
}
|
|
}
|