<?php

namespace Database\Seeders;

use App\Models\User;
use App\Enums\UserRole;
use App\Models\GrapeVariety;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // User::factory(10)->create();

        // create a default test user
        // User::updateOrCreate(
        //     ['email' => 'test@example.com'],
        //     [
        //         'name' => 'Test User',
        //         'username' => 'test',
        //         // model casts password => hashed, so plain text will be auto-hashed
        //         'password' => 'password123',
        //         'role' => UserRole::CUSTOMER,
        //     ]
        // );

        // // create an admin user (idempotent)
        // User::updateOrCreate(
        //     ['email' => 'admin@local'],
        //     [
        //         'name' => 'Administrator',
        //         'username' => 'admin',
        //         'password' => 'Admin@1234',
        //         'role' => UserRole::ADMIN,
        //     ]
        // );

        // Seed grape varieties and their variants first so other seeders can reference them
        $this->call([
            UserSeeder::class,
            WinerySeeder::class,
            GrapeVarietySeeder::class,
            VarietyVariationSeeder::class,
            VineyardRowSeeder::class,
            HarvestSeeder::class,
            WineSeeder::class,
            WineProductionSeeder::class,
            WateringSeeder::class,
            FertilizationSeeder::class,
            SprayingSeeder::class,
            PruningSeeder::class,
            PlannedTaskSeeder::class,
            PurchaseSeeder::class,
            EventSeeder::class,
        ]);
    }
}
