<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\Buku;
use App\Models\Anggota;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // Admin user
        User::create([
            'name' => 'Admin',
            'email' => 'admin@perpustakaan.com',
            'password' => Hash::make('password'),
            'role' => 'admin',
        ]);

        // Regular user
        User::create([
            'name' => 'User Test',
            'email' => 'user@perpustakaan.com',
            'password' => Hash::make('password'),
            'role' => 'user',
        ]);

        // Sample buku
        Buku::create([
            'judul' => 'Pemrograman Web dengan Laravel',
            'pengarang' => 'Adi Nugroho',
            'penerbit' => 'Informatika Bandung',
            'tahun_terbit' => 2023,
            'stok' => 5,
        ]);

        Buku::create([
            'judul' => 'Basis Data Lanjutan',
            'pengarang' => 'Fathansyah',
            'penerbit' => 'Informatika Bandung',
            'tahun_terbit' => 2020,
            'stok' => 3,
        ]);

        // Sample anggota
        Anggota::create([
            'nama' => 'Mahasiswa Test',
            'no_identitas' => 'E31230001',
            'jenis_anggota' => 'Mahasiswa',
            'no_ktp' => '3509012345678901',
            'prodi' => 'Manajemen Informatika',
            'no_hp' => '081234567890',
            'alamat' => 'Jl. Mastrip No. 164, Jember',
            'nama_wali' => 'Budi Santoso',
            'no_hp_wali' => '081298765432',
            'hubungan_wali' => 'Orang Tua',
        ]);

        $this->call([
            BukuTamuSeeder::class,
        ]);
    }
}

