2026-04-03 04:34:21 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
|
|
|
|
use App\Models\Division;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
|
|
class UserSeeder extends Seeder
|
|
|
|
|
{
|
|
|
|
|
public function run(): void
|
|
|
|
|
{
|
2026-04-04 12:56:13 +07:00
|
|
|
$divisions = Division::pluck('id')->toArray();
|
|
|
|
|
|
|
|
|
|
// super_admin
|
|
|
|
|
User::factory()->createOne([
|
|
|
|
|
'name' => 'Super Admin',
|
|
|
|
|
'email' => 'admin@admin.com',
|
|
|
|
|
'password' => bcrypt('admin'),
|
|
|
|
|
'phone' => '08123456789',
|
|
|
|
|
'status' => 'aktif',
|
|
|
|
|
])->assignRole('super_admin');
|
|
|
|
|
|
|
|
|
|
// 2 user per role
|
|
|
|
|
foreach (['ketua', 'bendahara', 'pengurus', 'auditor', 'anggota'] as $role) {
|
|
|
|
|
User::factory(2)->create(['division_id' => fake()->randomElement($divisions)])
|
|
|
|
|
->each(fn ($user) => $user->assignRole($role));
|
2026-04-03 04:34:21 +07:00
|
|
|
}
|
2026-04-04 12:56:13 +07:00
|
|
|
|
|
|
|
|
// 2 user tanpa role
|
|
|
|
|
User::factory(2)->create(['division_id' => fake()->randomElement($divisions)]);
|
2026-04-03 04:34:21 +07:00
|
|
|
}
|
|
|
|
|
}
|