<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\User;
use App\Enums\UserRole;
use Illuminate\Support\Facades\Hash;

class AdminUserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Check if admin user already exists
        $adminExists = User::where('username', 'admin')->exists();

        if (!$adminExists) {
            User::create([
                'name' => 'Administrator',
                'username' => 'admin',
                'email' => 'admin@winery.local',
                'password' => Hash::make('Admin@1234'),
                'role' => UserRole::ADMIN,
            ]);

            $this->command->info('✓ Admin user created (username: admin, password: Admin@1234)');
        } else {
            $this->command->info('Admin user already exists');
        }
    }
}
