<?php

namespace Database\Seeders;

use App\Models\MataPelajaran;
use App\Models\TingkatSekolah;
use Illuminate\Database\Seeder;

class MataPelajaranSeeder extends Seeder
{
    public function run(): void
    {
        $mts = TingkatSekolah::where('kode', 'mts')->first();
        if (!$mts) return;

        $mapel = [
            ['nama' => 'Matematika',               'kode' => 'MTK'],
            ['nama' => 'Bahasa Indonesia',          'kode' => 'BIND'],
            ['nama' => 'Bahasa Inggris',            'kode' => 'BING'],
            ['nama' => 'IPA',                       'kode' => 'IPA'],
            ['nama' => 'IPS',                       'kode' => 'IPS'],
            ['nama' => 'Pendidikan Agama Islam',    'kode' => 'PAI'],
            ['nama' => 'PKn',                       'kode' => 'PKN'],
            ['nama' => 'Bahasa Arab',               'kode' => 'BARAB'],
            ['nama' => 'Fikih',                     'kode' => 'FQH'],
            ['nama' => 'Akidah Akhlak',             'kode' => 'AA'],
        ];

        foreach ($mapel as $item) {
            MataPelajaran::firstOrCreate(
                ['kode' => $item['kode'], 'tingkat_sekolah_id' => $mts->id],
                ['nama' => $item['nama']]
            );
        }
    }
}
