<?php

namespace Database\Seeders;

use App\Models\KategoriEvent;
use App\Models\Lokasi;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class RoleSeeder extends Seeder
{
    public function run(): void
    {
        // Buat kategori & lokasi default (required oleh EventTiketSeeder)
        KategoriEvent::firstOrCreate(
            ['nama_kategori' => '-'],
            ['nama_kategori' => '-']
        );

        Lokasi::firstOrCreate(
            ['nama_lokasi' => '-'],
            [
                'nama_lokasi' => '-',
                'alamat' => '-',
                'kapasitas' => 0,
            ]
        );

        // Buat admin default jika belum ada
        User::firstOrCreate(
            ['email' => 'admin@konser.com'],
            [
                'name' => 'Admin',
                'username' => 'admin',
                'password' => Hash::make('admin123'),
                'role' => 'admin',
            ]
        );
    }
}