<?php

namespace Database\Seeders;

use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // \App\Models\User::factory(10)->create();
        $this->call(ImportEntitySeeder::class);
        // User::factory(10)->create();

        // Ensure a default test user exists (idempotent)
        \App\Models\User::query()->updateOrCreate(
            ['email' => 'test@example.com'],
            [
                'name' => 'Test User',
                'password' => Hash::make('password'),
                'email_verified_at' => now(),
            ]
        );

        $this->call([
            AccountTypeSeeder::class,
            PaymentSettingSeeder::class,
            ArchiveEntitySeeder::class,
            PersonSeeder::class,
            SegmentSeeder::class,
            ActionSeeder::class,
            EventSeeder::class,
            ImportTemplateSeeder::class,
            TestUserSeeder::class,
            ProductionUserSeeder::class,
            AdditionalProductionUsersSeeder::class,
            // Roles/permissions: ensure Manager role exists (admin, manager, staff, viewer)
            AddManagerRoleSeeder::class,
        ]);
    }
}
