LMIV-SNACKAUTOMAT/database/seeders/TenantSeeder.php

88 lines
2.9 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class TenantSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Super-Admin erstellen (ohne Mandant)
User::create([
'name' => 'Super Administrator',
'email' => 'superadmin@snackautomat.local',
'password' => Hash::make('password'),
'role' => 'super_admin',
'tenant_id' => null,
'is_active' => true,
]);
// Mandant 1: Bürogebäude A
$tenant1 = Tenant::create([
'name' => 'Bürogebäude A',
'slug' => 'buerogebaeude-a',
'description' => 'Hauptstandort im Bürogebäude A mit 3 Snackautomaten',
'is_active' => true,
]);
// Mandanten-Admin für Bürogebäude A
User::create([
'name' => 'Admin Bürogebäude A',
'email' => 'admin@buerogebaeude-a.local',
'password' => Hash::make('password'),
'role' => 'tenant_admin',
'tenant_id' => $tenant1->id,
'is_active' => true,
]);
// Mandant 2: Kantinen-Service
$tenant2 = Tenant::create([
'name' => 'Kantinen-Service GmbH',
'slug' => 'kantinen-service',
'description' => 'Kantinen-Service mit mehreren Standorten',
'is_active' => true,
]);
// Mandanten-Admin für Kantinen-Service
User::create([
'name' => 'Admin Kantinen-Service',
'email' => 'admin@kantinen-service.local',
'password' => Hash::make('password'),
'role' => 'tenant_admin',
'tenant_id' => $tenant2->id,
'is_active' => true,
]);
// Mandant 3: Campus-Automaten
$tenant3 = Tenant::create([
'name' => 'Campus-Automaten',
'slug' => 'campus-automaten',
'description' => 'Snackautomaten auf dem Universitätscampus',
'is_active' => true,
]);
// Mandanten-Admin für Campus-Automaten
User::create([
'name' => 'Admin Campus',
'email' => 'admin@campus-automaten.local',
'password' => Hash::make('password'),
'role' => 'tenant_admin',
'tenant_id' => $tenant3->id,
'is_active' => true,
]);
$this->command->info('Mandanten und Benutzer erstellt:');
$this->command->line('- Super-Admin: superadmin@snackautomat.local / password');
$this->command->line('- Bürogebäude A: admin@buerogebaeude-a.local / password');
$this->command->line('- Kantinen-Service: admin@kantinen-service.local / password');
$this->command->line('- Campus-Automaten: admin@campus-automaten.local / password');
}
}