<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Siswa;

class SiswaSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Menggunakan updateOrCreate agar jika dijalankan ulang tidak error "Duplicate Entry"
        Siswa::updateOrCreate(
            ['nisn' => '0098273641'], // Cek berdasarkan NISN
            [
                'nama' => 'Malle Muhammad',
                'kelas' => 'XII-IPA',
                'jenis_kelamin' => 'L',
                'qr_code' => 'MA-12345',
            ]
        );

        // Tambah contoh satu siswa lagi biar tabelnya gak sepi
        Siswa::updateOrCreate(
            ['nisn' => '0098273642'],
            [
                'nama' => 'Ahmad Fikri',
                'kelas' => 'XII-IPS',
                'jenis_kelamin' => 'L',
                'qr_code' => 'MA-12346',
            ]
        );
    }
}
