models:
  # 1. MADRASAH
  Madrasah:
    kode: string:10 unique index
    nama: string
    alamat: text nullable
    logo: string nullable
    timestamps: true
    softDeletes: true
    relationships:
      hasMany: Kelas, Kamar, Siswa, User

  # 2. TAHUN AJARAN
  TahunAjaran:
    nama: string:20 # 2024/2025
    is_aktif: boolean default:false
    timestamps: true
    softDeletes: true
    relationships:
      hasMany: RiwayatKelas, PresensiMadrasah, PresensiAsrama

  # 3. KELAS (untuk Madrasah)
  Kelas:
    madrasah_id: id foreign:madrasah
    tingkat: string:10 # VII, VIII, IX, X, XI, XII
    nama: string:50 # A, B, IPA 1, IPS 1
    wali_kelas_id: id foreign:users nullable
    wali_kamar_id: id foreign:users nullable
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: Madrasah, WaliKelas:User
      hasMany: Siswa, PresensiMadrasah, RiwayatKelas

  # 4. KAMAR (untuk Asrama)
  Kamar:
    madrasah_id: id foreign:madrasah
    nama_kamar: string:50 # Kamar 1, Kamar 2
    jenis_kelamin: enum:L,P
    kapasitas: integer unsigned default:10
    wali_kamar_id: id foreign:users nullable
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: Madrasah, WaliKamar:User
      hasMany: Siswa, PresensiAsrama

  # 5. SISWA
  Siswa:
    madrasah_id: id foreign:madrasah
    kelas_id: id foreign:kelas # Current active class
    nisn: string:20 unique index
    nis: string:20 nullable index
    nik: string:20 nullable index
    nama: string
    jenis_kelamin: enum:L,P
    tempat_lahir: string nullable
    tanggal_lahir: date nullable
    status_tempat_tinggal: enum:asrama,non_asrama
    kamar_id: id foreign:kamar nullable
    # Data Orang Tua
    no_kk: string:20 nullable
    nama_ayah: string nullable
    nik_ayah: string:20 nullable
    pendidikan_ayah: string nullable
    pekerjaan_ayah: string nullable
    nama_ibu: string nullable
    nik_ibu: string:20 nullable
    pendidikan_ibu: string nullable
    pekerjaan_ibu: string nullable
    no_hp_ortu: string:20 nullable
    # Alamat
    alamat: text nullable
    provinsi: string nullable
    kabupaten_kota: string nullable
    kecamatan: string nullable
    desa_kelurahan: string nullable
    kode_pos: string:10 nullable
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: Madrasah, Kelas, Kamar
      hasMany: DetailPresensiMadrasah, DetailPresensiAsrama, RiwayatKelas

  # 6. RIWAYAT KELAS (History)
  RiwayatKelas:
    siswa_id: id foreign:siswa
    kelas_id: id foreign:kelas
    tahun_ajaran_id: id foreign:tahun_ajaran
    status: enum:aktif,lulus,pindah,do
    keterangan: text nullable
    timestamps: true
    relationships:
      belongsTo: Siswa, Kelas, TahunAjaran

  # # 7. USERS (Role Management)
  # User:
  #   name: string
  #   email: string unique
  #   email_verified_at: timestamp nullable
  #   password: string
  #   role: enum:kepala_madrasah,wakil_kesiswaan,wali_kelas,koordinator_asrama,wali_kamar
  #   madrasah_id: id foreign:madrasah nullable
  #   no_hp: string:20 nullable
  #   is_active: boolean default:true
  #   remember_token: string:100 nullable
  #   timestamps: true
  #   softDeletes: true
  #   relationships:
  #     belongsTo: Madrasah
  #     hasMany: PresensiMadrasah, PresensiAsrama

  # ==============================================================================
  # PRESENSI MADRASAH
  # ==============================================================================

  # 8. JENIS PRESENSI MADRASAH
  JenisPresensiMadrasah:
    nama: string # Apel Pagi, Upacara, Muhadarah, Literasi
    kategori: enum:kbm,upacara,literasi,ekskul,lainnya
    deskripsi: text nullable
    madrasah_id: id foreign:madrasah nullable # NULL = berlaku untuk semua
    is_active: boolean default:true
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: Madrasah
      hasMany: PresensiMadrasah

  # 9. PRESENSI MADRASAH
  PresensiMadrasah:
    tanggal: date
    tahun_ajaran_id: id foreign:tahun_ajaran
    jenis_presensi_madrasah_id: id foreign:jenis_presensi_madrasah
    kelas_id: id foreign:kelas
    user_id: id foreign:users # Yang input
    keterangan: text nullable
    is_locked: boolean default:false # Tidak bisa edit lagi
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: TahunAjaran, JenisPresensiMadrasah, Kelas, User
      hasMany: DetailPresensiMadrasah

  # 10. DETAIL PRESENSI MADRASAH
  DetailPresensiMadrasah:
    presensi_madrasah_id: id foreign:presensi_madrasah
    siswa_id: id foreign:siswa
    status: enum:hadir,sakit,izin,alpha
    keterangan: text nullable
    timestamps: true
    relationships:
      belongsTo: PresensiMadrasah, Siswa

  # ==============================================================================
  # PRESENSI ASRAMA
  # ==============================================================================

  # 11. JENIS PRESENSI ASRAMA
  JenisPresensiAsrama:
    nama: string # Shalat Subuh, Dzuhur, Tadarus, Tahfidz, dll
    kategori: enum:ibadah,bahasa,kebersihan,olahraga,makan,pendidikan,lainnya
    sifat: enum:wajib,opsional # Renamed from old kategori
    deskripsi: text nullable
    is_active: boolean default:true
    timestamps: true
    softDeletes: true
    relationships:
      hasMany: PresensiAsrama

  # 12. PRESENSI ASRAMA
  PresensiAsrama:
    tanggal: date
    tahun_ajaran_id: id foreign:tahun_ajaran
    jenis_presensi_asrama_id: id foreign:jenis_presensi_asrama
    kamar_id: id foreign:kamar
    user_id: id foreign:users # Yang input
    keterangan: text nullable
    is_locked: boolean default:false # Tidak bisa edit lagi
    timestamps: true
    softDeletes: true
    relationships:
      belongsTo: TahunAjaran, JenisPresensiAsrama, Kamar, User
      hasMany: DetailPresensiAsrama

  # 13. DETAIL PRESENSI ASRAMA
  DetailPresensiAsrama:
    presensi_asrama_id: id foreign:presensi_asrama
    siswa_id: id foreign:siswa
    status: enum:hadir,sakit,izin,alpha
    keterangan: text nullable
    timestamps: true
    relationships:
      belongsTo: PresensiAsrama, Siswa

seeders: Madrasah, TahunAjaran, Kelas, Kamar, Siswa, RiwayatKelas, JenisPresensiMadrasah, PresensiMadrasah, DetailPresensiMadrasah, JenisPresensiAsrama, PresensiAsrama, DetailPresensiAsrama
