# DUMP PROYEK: 3 DATABASE
> Diekstrak pada: 2026-10-04 21:08:30

## File: `database/seeders/DatabaseSeeder.php`
```php
<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // User::factory(10)->create();

        User::factory()->create([
            'name' => 'Test User',
            'email' => 'test@example.com',
        ]);
    }
}

```

## File: `database/seeders/UserSeeder.php`
```php
<?php

namespace Database\Seeders;

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

class UserSeeder extends Seeder
{
    public function run(): void
    {
        User::create([
            'name' => 'Administrator',
            'username' => '000000',
            'password' => Hash::make('12345678'),
            'role' => 'admin'
        ]);
    }
}
```

## File: `database/migrations/2026_08_13_034524_create_galeris_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('galeris', function (Blueprint $table) {
            $table->id();
            $table->string('judul');
            $table->text('deskripsi')->nullable();
            $table->enum('tipe', ['foto', 'video'])->default('foto');
            $table->string('file_path')->nullable(); // Untuk menyimpan nama file WebP
            $table->string('video_url')->nullable(); // Untuk menyimpan URL video eksternal
            $table->timestamps();
        });
    }

    public function down(): void {
        Schema::dropIfExists('galeris');
    }
};
```

## File: `database/migrations/2026_07_04_184703_add_tahun_ajaran_id_to_siswas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            // Menambahkan kolom tahun_ajaran_id setelah kolom kelas_id
            $table->foreignId('tahun_ajaran_id')
                  ->nullable()
                  ->after('kelas_id')
                  ->constrained('tahun_ajarans')
                  ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            // Menghapus foreign key dan kolom jika migrasi di-rollback
            $table->dropForeign(['tahun_ajaran_id']);
            $table->dropColumn('tahun_ajaran_id');
        });
    }
};
```

## File: `database/migrations/2026_07_03_073828_add_hijriyah_fields_to_tahun_ajarans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('tahun_ajarans', function (Blueprint $table) {
            // Menambahkan kolom tahun_ajaran_hijriyah tepat setelah kolom tahun_ajaran
            $table->string('tahun_ajaran_hijriyah')->nullable()->after('tahun_ajaran');
            
            // Menambahkan kolom tahun_ppdb_hijriyah tepat setelah kolom tahun_ppdb
            $table->string('tahun_ppdb_hijriyah')->nullable()->after('tahun_ppdb');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('tahun_ajarans', function (Blueprint $table) {
            // Menghapus kolom jika dilakukan rollback
            $table->dropColumn(['tahun_ajaran_hijriyah', 'tahun_ppdb_hijriyah']);
        });
    }
};
```

## File: `database/migrations/2026_07_06_031334_add_tmt_pengangkatan_hijriyah_to_gurus_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->string('tmt_pengangkatan_hijriyah')
                  ->nullable()
                  ->after('tmt_pengangkatan');
        });
    }

    public function down(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->dropColumn('tmt_pengangkatan_hijriyah');
        });
    }
};
```

## File: `database/migrations/2026_08_13_053227_create_pesan_kontaks_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('pesan_kontaks', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->string('email')->nullable();
            $table->string('no_hp')->nullable();
            $table->string('subjek')->nullable();
            $table->text('pesan');
            $table->boolean('is_read')->default(false); // Penanda sudah dibaca
            $table->timestamps();
        });
    }
    public function down(): void { Schema::dropIfExists('pesan_kontaks'); }
};
```

## File: `database/migrations/2026_07_13_152059_create_kategori_keuangans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('kategori_keuangans', function (Blueprint $table) {
            $table->id();
            $table->foreignId('jenjang_id')->constrained('jenjang_kelas')->onDelete('cascade');
            $table->string('nama');
            $table->enum('tipe', ['Bulanan', 'Per Semester', 'Tahunan', 'Sekali Bayar', 'Bebas']);
            $table->integer('nominal')->default(0);
            $table->text('keterangan')->nullable();
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('kategori_keuangans');
    }
};
```

## File: `database/migrations/2026_06_13_124712_create_siswas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('siswas', function (Blueprint $table) {
            $table->id();
            
            // 1. DATA AKADEMIK & PENDAFTARAN
            $table->foreignId('kelas_id')->nullable()->constrained('kelas')->nullOnDelete(); // Relasi ke tabel kelas
            $table->string('jenis_pendaftaran')->nullable(); // Baru / Pindahan
            $table->string('status_siswa')->default('Aktif'); // Aktif / Lulus / Pindah / Keluar
            $table->string('foto')->nullable();

            // 2. IDENTITAS UTAMA SISWA
            $table->string('nisn')->nullable()->unique();
            $table->string('nis')->nullable();
            $table->string('nama_lengkap');
            $table->string('tempat_lahir')->nullable();
            $table->date('tanggal_lahir')->nullable();
            $table->enum('jenis_kelamin', ['L', 'P']);
            $table->string('nik')->nullable();
            $table->string('agama')->default('Islam');
            $table->string('status_keluarga')->nullable(); // Anak Kandung, dll
            $table->integer('anak_ke')->nullable();
            $table->integer('jumlah_saudara_kandung')->nullable();
            $table->string('no_reg_akta_lahir')->nullable();
            $table->string('hobi')->nullable();
            $table->string('cita_cita')->nullable();

            // 3. KESEJAHTERAAN & BANTUAN SOSIAL
            $table->string('no_kk')->nullable();
            $table->string('no_kip')->nullable();
            $table->string('no_pkh')->nullable();
            $table->string('no_kks')->nullable();

            // 4. DOMISILI / ALAMAT SISWA
            $table->string('nama_jalan')->nullable();
            $table->string('dusun')->nullable();
            $table->string('rt', 10)->nullable();
            $table->string('rw', 10)->nullable();
            $table->string('desa')->nullable();
            $table->string('kecamatan')->nullable();
            $table->string('kabupaten')->nullable();
            $table->string('propinsi')->nullable();
            $table->string('kode_pos', 10)->nullable();

            // 5. RIWAYAT PENDIDIKAN SEBELUMNYA
            $table->string('asal_sekolah')->nullable();
            $table->string('no_seri_ijazah')->nullable();

            // 6. DATA AYAH
            $table->string('nama_ayah')->nullable();
            $table->string('nik_ayah')->nullable();
            $table->string('pekerjaan_ayah')->nullable();
            $table->string('penghasilan_ayah')->nullable();
            $table->string('pendidikan_akhir_ayah')->nullable();
            $table->string('tahun_lahir_ayah', 4)->nullable();

            // 7. DATA IBU / WALI
            $table->string('nama_ibu')->nullable();
            $table->string('nik_ibu')->nullable();
            $table->string('pekerjaan_ibu')->nullable();
            $table->string('penghasilan_ibu')->nullable();
            $table->string('pendidikan_akhir_ibu')->nullable();
            $table->string('tahun_lahir_ibu', 4)->nullable();
            
            $table->string('no_hp')->nullable(); // Nomor HP Ortu/Wali

            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('siswas');
    }
};
```

## File: `database/migrations/2026_06_14_072844_create_genders_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('genders', function (Blueprint $table) {
            $table->id();
            $table->string('nama_gender')->unique(); 
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('genders');
    }
};
```

## File: `database/migrations/2026_06_07_172018_create_kelas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('kelas', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tingkat_kelas_id')->constrained('tingkat_kelas')->onDelete('cascade');
            $table->string('nama_kelas'); 
    
            $table->integer('kapasitas')->nullable(); 
            
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('kelas');
    }
};
```

## File: `database/migrations/2026_07_03_065252_add_hijriyah_to_tahun_ajarans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('tahun_ajarans', function (Blueprint $table) {
            $table->string('tgl_mulai_hijriyah')->nullable()->after('tgl_mulai');
            $table->string('tgl_akhir_hijriyah')->nullable()->after('tgl_akhir');
        });
    }

    public function down(): void
    {
        Schema::table('tahun_ajarans', function (Blueprint $table) {
            $table->dropColumn(['tgl_mulai_hijriyah', 'tgl_akhir_hijriyah']);
        });
    }
};

```

## File: `database/migrations/2026_08_13_053217_create_testimonis_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('testimonis', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->string('peran'); // Contoh: Alumni 2022, Tokoh Masyarakat
            $table->string('foto')->nullable();
            $table->text('pesan');
            $table->timestamps();
        });
    }
    public function down(): void { Schema::dropIfExists('testimonis'); }
};
```

## File: `database/migrations/2026_07_22_043853_create_wali_kelas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('wali_kelas', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->cascadeOnDelete();
            $table->foreignId('semester_id')->constrained('semesters')->cascadeOnDelete();
            $table->foreignId('kelas_id')->constrained('kelas')->cascadeOnDelete();
            
            // Nullable karena kelas campuran tidak menggunakan detail gender
            $table->foreignId('kelas_detail_id')->nullable()->constrained('kelas_details')->cascadeOnDelete();
            
            $table->foreignId('guru_id')->constrained('gurus')->cascadeOnDelete();
            $table->timestamps();

            // Mencegah duplikasi data: 1 Kelas (atau 1 Kelompok Gender di kelas tsb) 
            // pada TA dan Semester yang sama hanya boleh memiliki 1 Wali Kelas
            $table->unique(['tahun_ajaran_id', 'semester_id', 'kelas_id', 'kelas_detail_id'], 'unique_wali_kelas');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wali_kelas');
    }
};
```

## File: `database/migrations/2026_08_17_121800_create_nilais_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('nilais', function (Blueprint $table) {
            $table->id();
            
            // Relasi Utama
            $table->foreignId('siswa_id')->constrained('siswas')->cascadeOnDelete();
            $table->foreignId('guru_mapel_id')->constrained('guru_mapels')->cascadeOnDelete();
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->cascadeOnDelete();
            $table->foreignId('semester_id')->constrained('semesters')->cascadeOnDelete();
            
            // Komponen Nilai
            $table->decimal('nilai_kehadiran', 5, 2)->default(0); // Bobot 10%
            $table->decimal('nilai_tugas', 5, 2)->default(0);     // Bobot 20%
            $table->decimal('nilai_uts', 5, 2)->default(0);       // Bobot 30%
            $table->decimal('nilai_uas', 5, 2)->default(0);       // Bobot 40%
            
            // Hasil Akhir
            $table->decimal('total_nilai', 5, 2)->default(0);
            $table->string('grade', 2)->nullable();
            $table->string('keterangan')->nullable();
            
            $table->timestamps();

            // Mencegah guru menginput 2 nilai untuk siswa dan mapel yang sama di semester yang sama
            $table->unique(['siswa_id', 'guru_mapel_id', 'tahun_ajaran_id', 'semester_id'], 'unik_nilai_akademik');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('nilais');
    }
};
```

## File: `database/migrations/2026_07_14_070958_create_pembayaran_keuangans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('pembayaran_keuangans', function (Blueprint $table) {
            $table->id();
            $table->foreignId('siswa_id')->constrained('siswas')->onDelete('cascade');
            $table->foreignId('tarif_keuangan_id')->constrained('tarif_keuangans')->onDelete('cascade');
            $table->integer('nominal_bayar');
            $table->date('tanggal_bayar');
            $table->text('keterangan')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('pembayaran_keuangans');
    }
};

```

## File: `database/migrations/2026_08_15_053252_add_gambar_ilustrasi_to_ppdb_settings_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('ppdb_settings', function (Blueprint $table) {
            $table->string('gambar_ilustrasi')->nullable()->after('brosur_file');
        });
    }

    public function down(): void
    {
        Schema::table('ppdb_settings', function (Blueprint $table) {
            $table->dropColumn('gambar_ilustrasi');
        });
    }
};
```

## File: `database/migrations/2026_08_12_182051_create_beritas_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('beritas', function (Blueprint $table) {
            $table->id();
            $table->foreignId('kategori_berita_id')->constrained('kategori_beritas')->onDelete('restrict');
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
            $table->string('judul');
            $table->string('slug')->unique();
            $table->text('excerpt')->nullable();
            $table->longText('konten');
            $table->string('thumbnail')->nullable();
            $table->enum('status', ['draft', 'publish'])->default('publish');
            $table->string('seo_title')->nullable();
            $table->string('seo_keywords')->nullable();
            $table->text('seo_description')->nullable();
            $table->integer('views')->default(0);
            $table->timestamps();
        });
    }
    public function down(): void {
        Schema::dropIfExists('beritas');
    }
};
```

## File: `database/migrations/2026_07_13_165504_create_tarif_keuangans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('tarif_keuangans', function (Blueprint $table) {
            $table->id();
            $table->foreignId('jenjang_id')->constrained('jenjang_kelas')->onDelete('cascade');
            $table->foreignId('kategori_id')->constrained('kategori_keuangans')->onDelete('cascade');
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->onDelete('cascade');
            $table->foreignId('semester_id')->nullable()->constrained('semesters')->nullOnDelete();
            $table->integer('nominal');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('tarif_keuangans');
    }
};
```

## File: `database/migrations/2026_06_11_040654_add_foto_to_gurus_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->string('foto')->nullable()->after('email');
        });
    }

    public function down(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->dropColumn('foto');
        });
    }
};
```

## File: `database/migrations/2026_07_14_234904_create_jadwal_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('jadwal_mapels', function (Blueprint $table) {
            $table->id();
            
            // Relasi ke Data Master dan Ruang Kelas
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->onDelete('cascade');
            $table->foreignId('semester_id')->constrained('semesters')->onDelete('cascade');
            $table->foreignId('kelas_id')->constrained('kelas')->onDelete('cascade');
            
            // Relasi ke tabel Ploting Guru Mapel (Satu ID ini mewakili Siapa Guru-nya dan Apa Mapel-nya)
            $table->foreignId('guru_mapel_id')->constrained('guru_mapels')->onDelete('cascade'); 
            
            // Kolom Jadwal
            $table->enum('hari', ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Ahad']);
            $table->time('jam_mulai');
            $table->time('jam_selesai');
            
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('jadwal_mapels');
    }
};
```

## File: `database/migrations/2026_08_18_141314_add_jenjang_id_to_ppdbs_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('ppdbs', function (Blueprint $table) {
            // Menambahkan kolom jenjang_id
            $table->foreignId('jenjang_id')->nullable()->after('tahun_ajaran_id')->constrained('jenjang_kelas')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('ppdbs', function (Blueprint $table) {
            $table->dropForeign(['jenjang_id']);
            $table->dropColumn('jenjang_id');
        });
    }
};
```

## File: `database/migrations/0001_01_01_000002_create_jobs_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('jobs', function (Blueprint $table) {
            $table->id();
            $table->string('queue')->index();
            $table->longText('payload');
            $table->unsignedSmallInteger('attempts');
            $table->unsignedInteger('reserved_at')->nullable();
            $table->unsignedInteger('available_at');
            $table->unsignedInteger('created_at');
        });

        Schema::create('job_batches', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->string('name');
            $table->integer('total_jobs');
            $table->integer('pending_jobs');
            $table->integer('failed_jobs');
            $table->longText('failed_job_ids');
            $table->mediumText('options')->nullable();
            $table->integer('cancelled_at')->nullable();
            $table->integer('created_at');
            $table->integer('finished_at')->nullable();
        });

        Schema::create('failed_jobs', function (Blueprint $table) {
            $table->id();
            $table->string('uuid')->unique();
            $table->string('connection');
            $table->string('queue');
            $table->longText('payload');
            $table->longText('exception');
            $table->timestamp('failed_at')->useCurrent();

            $table->index(['connection', 'queue', 'failed_at']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('jobs');
        Schema::dropIfExists('job_batches');
        Schema::dropIfExists('failed_jobs');
    }
};

```

## File: `database/migrations/2026_08_17_041615_penyesuaian_sistem_login_siswa.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        // 1. Tambah kolom is_active di tabel users untuk fungsi blokir login
        Schema::table('users', function (Blueprint $table) {
            $table->boolean('is_active')->default(true)->after('role');
        });

        // 2. Tambah relasi user_id di tabel siswas
        Schema::table('siswas', function (Blueprint $table) {
            $table->foreignId('user_id')->nullable()->after('id')->constrained('users')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            $table->dropForeign(['user_id']);
            $table->dropColumn('user_id');
        });

        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('is_active');
        });
    }
};
```

## File: `database/migrations/2026_05_26_032924_create_beranda_settings_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('beranda_settings', function (Blueprint $table) {
            $table->id();
            $table->string('hero_title'); // a. Judul besar
            $table->text('hero_subtitle'); // b. Sub judul
            $table->string('stat_siswa')->default('1500+'); // c1
            $table->string('stat_guru')->default('150+');   // c2
            $table->string('stat_lulusan')->default('500+'); // c3
            $table->timestamps();
        });
    }
    public function down(): void {
        Schema::dropIfExists('beranda_settings');
    }
};

```

## File: `database/migrations/2026_06_07_120208_create_semesters_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('semesters', function (Blueprint $table) {
            $table->id();
            $table->string('nama'); // Ganjil, Genap
            $table->boolean('is_active')->default(false);
            $table->timestamps();
        });

        // Insert data paten otomatis saat di-migrate
        DB::table('semesters')->insert([
            ['nama' => 'Ganjil', 'is_active' => true, 'created_at' => now(), 'updated_at' => now()],
            ['nama' => 'Genap', 'is_active' => false, 'created_at' => now(), 'updated_at' => now()],
        ]);
    }

    public function down(): void
    {
        Schema::dropIfExists('semesters');
    }
};
```

## File: `database/migrations/2026_06_13_230805_create_jenjang_kelas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('jenjang_kelas', function (Blueprint $table) {
            $table->id();
            $table->string('kode', 10)->unique(); 
            $table->string('nama_jenjang')->unique(); // Berubah dari nama_tingkatan
            $table->string('deskripsi')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('jenjang_kelas');
    }
};
```

## File: `database/migrations/2026_08_13_053212_create_ekstrakurikulers_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('ekstrakurikulers', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->text('deskripsi')->nullable();
            $table->string('foto')->nullable();
            $table->string('jadwal')->nullable();
            $table->string('pembina')->nullable();
            $table->timestamps();
        });
    }
    public function down(): void { Schema::dropIfExists('ekstrakurikulers'); }
};
```

## File: `database/migrations/2026_07_16_050843_add_target_gender_to_jadwal_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('jadwal_mapels', function (Blueprint $table) {
            // Menambahkan kolom target_gender setelah kelas_id
            $table->string('target_gender')->default('Campur')->after('kelas_id');
        });
    }

    public function down(): void
    {
        Schema::table('jadwal_mapels', function (Blueprint $table) {
            $table->dropColumn('target_gender');
        });
    }
};
```

## File: `database/migrations/2026_07_03_083129_create_ppdbs_table.php`
```php
<?php
// database/migrations/xxxx_xx_xx_xxxxxx_create_ppdbs_table.php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('ppdbs', function (Blueprint $table) {
            $table->id();
            $table->string('no_pendaftaran')->unique(); // Contoh: PPDB-2024-001
            $table->date('tanggal_daftar');
            
            // Relasi ke tabel kelas (bisa nullable jika belum ditentukan)
            $table->unsignedBigInteger('kelas_id')->nullable();
            $table->foreign('kelas_id')->references('id')->on('kelas')->onDelete('set null');

            // Identitas Dasar
            $table->string('nama_lengkap');
            $table->string('tempat_lahir')->nullable();
            $table->date('tanggal_lahir')->nullable();
            $table->enum('jenis_kelamin', ['L', 'P']);
            $table->string('agama')->default('Islam');
            
            // Akademik & Asal
            $table->enum('jenis_pendaftaran', ['Baru', 'Pindahan'])->default('Baru');
            $table->string('nis')->nullable();
            $table->string('nisn')->nullable();
            $table->string('asal_sekolah')->nullable();
            $table->string('no_hp')->nullable();
            
            // Status PPDB
            $table->enum('status', ['Verifikasi', 'Diterima', 'Ditolak', 'Cabut Berkas'])->default('Verifikasi');
            
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('ppdbs');
    }
};
```

## File: `database/migrations/0001_01_01_000000_create_users_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('username')->unique(); // PERBAIKAN: Menggunakan username (bukan email)
            $table->string('password');
            $table->enum('role', ['admin', 'guru', 'siswa'])->default('siswa'); // PERBAIKAN: Hak akses
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create('password_reset_tokens', function (Blueprint $table) {
            $table->string('email')->primary();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });

        Schema::create('sessions', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->foreignId('user_id')->nullable()->index();
            $table->string('ip_address', 45)->nullable();
            $table->text('user_agent')->nullable();
            $table->longText('payload');
            $table->integer('last_activity')->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
        Schema::dropIfExists('password_reset_tokens');
        Schema::dropIfExists('sessions');
    }
};
```

## File: `database/migrations/2026_07_13_170056_remove_nominal_from_kategori_keuangans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::table('kategori_keuangans', function (Blueprint $table) {
            // Menghapus kolom nominal karena sudah dipindah ke tabel Tarif
            $table->dropColumn('nominal');
        });
    }

    public function down()
    {
        Schema::table('kategori_keuangans', function (Blueprint $table) {
            $table->integer('nominal')->default(0);
        });
    }
};
```

## File: `database/migrations/2026_06_14_085229_create_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('mapels', function (Blueprint $table) {
            $table->id();
            $table->foreignId('jenjang_kelas_id')->constrained('jenjang_kelas')->onDelete('cascade');
            $table->foreignId('kategori_mapel_id')->constrained('kategori_mapels')->onDelete('cascade');
            $table->string('nama_mapel');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('mapels');
    }
};
```

## File: `database/migrations/2026_07_14_212106_update_guru_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('guru_mapels', function (Blueprint $table) {
            // 1. Hapus Foreign Key Constraints lama terlebih dahulu
            $table->dropForeign(['tahun_ajaran_id']);
            $table->dropForeign(['semester_id']);
            $table->dropForeign(['kelas_id']);
            
            // 2. Hapus Unique Index lama
            $table->dropUnique('guru_mapel_unique');

            // 3. Hapus Kolom yang sudah tidak digunakan
            $table->dropColumn(['tahun_ajaran_id', 'semester_id', 'kelas_id']);

            // 4. Tambahkan Unique Index baru (Guru + Mapel)
            $table->unique(['guru_id', 'mapel_id'], 'guru_mapel_unique');
        });
    }

    public function down(): void
    {
        Schema::table('guru_mapels', function (Blueprint $table) {
            // Kembalikan struktur jika migrasi ini dibatalkan (rollback)
            $table->dropUnique('guru_mapel_unique');
            
            $table->foreignId('tahun_ajaran_id')->after('id')->constrained('tahun_ajarans')->onDelete('cascade');
            $table->foreignId('semester_id')->after('tahun_ajaran_id')->constrained('semesters')->onDelete('cascade');
            $table->foreignId('kelas_id')->after('guru_id')->constrained('kelas')->onDelete('cascade');
            
            $table->unique(['tahun_ajaran_id', 'semester_id', 'kelas_id', 'mapel_id'], 'guru_mapel_unique');
        });
    }
};
```

## File: `database/migrations/2026_08_13_161039_create_ppdb_settings_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('ppdb_settings', function (Blueprint $table) {
            $table->id();
            $table->string('judul')->default('Pendaftaran Peserta Didik Baru');
            $table->text('deskripsi')->nullable();
            $table->json('jadwal')->nullable(); // Menyimpan 4 tahapan jadwal
            $table->string('brosur_file')->nullable(); // Path file PDF/Gambar
            $table->timestamps();
        });
    }

    public function down(): void {
        Schema::dropIfExists('ppdb_settings');
    }
};
```

## File: `database/migrations/2026_08_13_053237_add_public_features_to_existing_tables.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::table('beranda_settings', function (Blueprint $table) {
            $table->json('hero_images')->nullable()->after('hero_subtitle');
            $table->string('kepsek_nama')->nullable();
            $table->string('kepsek_foto')->nullable();
            $table->text('kepsek_sambutan')->nullable();
        });
        Schema::table('gurus', function (Blueprint $table) {
            $table->boolean('tampil_publik')->default(true)->after('status_kepegawaian');
        });
        Schema::table('staffs', function (Blueprint $table) {
            $table->boolean('tampil_publik')->default(true)->after('jabatan_id');
        });
    }

    public function down(): void {
        Schema::table('beranda_settings', function (Blueprint $table) {
            $table->dropColumn(['hero_images', 'kepsek_nama', 'kepsek_foto', 'kepsek_sambutan']);
        });
        Schema::table('gurus', function (Blueprint $table) { $table->dropColumn('tampil_publik'); });
        Schema::table('staffs', function (Blueprint $table) { $table->dropColumn('tampil_publik'); });
    }
};
```

## File: `database/migrations/2026_07_12_042930_add_dokumen_fields_to_gurus_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->string('file_ijazah')->nullable()->after('foto');
            $table->string('file_ktp')->nullable()->after('file_ijazah');
            $table->string('file_kk')->nullable()->after('file_ktp');
            $table->string('file_npwp')->nullable()->after('file_kk');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('gurus', function (Blueprint $table) {
            $table->dropColumn(['file_ijazah', 'file_ktp', 'file_kk', 'file_npwp']);
        });
    }
};
```

## File: `database/migrations/2026_08_15_063909_add_google_maps_iframe_to_profil_sekolahs_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('profil_sekolahs', function (Blueprint $table) {
            $table->text('google_maps_iframe')->nullable()->after('alamat');
        });
    }

    public function down(): void
    {
        Schema::table('profil_sekolahs', function (Blueprint $table) {
            $table->dropColumn('google_maps_iframe');
        });
    }
};
```

## File: `database/migrations/2026_08_13_042041_add_batch_id_to_galeris_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::table('galeris', function (Blueprint $table) {
            // Menambahkan kolom batch_id setelah kolom tipe
            $table->string('batch_id')->nullable()->after('tipe');
        });
    }

    public function down(): void {
        Schema::table('galeris', function (Blueprint $table) {
            $table->dropColumn('batch_id');
        });
    }
};
```

## File: `database/migrations/0001_01_01_000001_create_cache_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('cache', function (Blueprint $table) {
            $table->string('key')->primary();
            $table->mediumText('value');
            $table->bigInteger('expiration')->index();
        });

        Schema::create('cache_locks', function (Blueprint $table) {
            $table->string('key')->primary();
            $table->string('owner');
            $table->bigInteger('expiration')->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('cache');
        Schema::dropIfExists('cache_locks');
    }
};

```

## File: `database/migrations/2026_07_04_192812_add_file_dokumen_to_siswas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            $table->string('file_ktp')->nullable()->after('no_hp');
            $table->string('file_kk')->nullable()->after('file_ktp');
            $table->string('file_kip')->nullable()->after('file_kk');
            $table->string('file_pkh')->nullable()->after('file_kip');
            $table->string('file_kks')->nullable()->after('file_pkh');
        });
    }

    public function down(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            $table->dropColumn(['file_ktp', 'file_kk', 'file_kip', 'file_pkh', 'file_kks']);
        });
    }
};
```

## File: `database/migrations/2026_06_14_200000_create_tingkat_kelas_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('tingkat_kelas', function (Blueprint $table) {
            $table->id();
            // Relasi ke tabel jenjang_kelas
            $table->foreignId('jenjang_kelas_id')->constrained('jenjang_kelas')->onDelete('cascade');
            
            // Kolom KODE dihapus dari sini
            $table->string('nama_tingkat'); // Cnth: Kelas 1, Kelas VII
            $table->string('deskripsi')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('tingkat_kelas');
    }
};
```

## File: `database/migrations/2026_07_25_085649_penyesuaian_tabel_users_untuk_login.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            // 1. Menghapus kolom email bawaan Laravel yang tidak kita pakai
            $table->dropColumn(['email', 'email_verified_at']);

            // 2. Menambahkan kolom username dan role
            $table->string('username')->unique()->after('name');
            $table->enum('role', ['admin', 'guru', 'siswa'])->default('siswa')->after('password');
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            // Mengembalikan ke kondisi semula jika di-rollback
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            
            $table->dropColumn(['username', 'role']);
        });
    }
};
```

## File: `database/migrations/2026_08_15_070722_add_siswa_id_to_testimonis_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('testimonis', function (Blueprint $table) {
            // Menambahkan relasi ke tabel siswas
            $table->foreignId('siswa_id')->nullable()->after('id')->constrained('siswas')->cascadeOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('testimonis', function (Blueprint $table) {
            $table->dropForeign(['siswa_id']);
            $table->dropColumn('siswa_id');
        });
    }
};
```

## File: `database/migrations/2026_06_10_171059_create_gurus_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('gurus', function (Blueprint $table) {
            $table->id();
            
            // ==========================================
            // FASE 1: IDENTITAS UTAMA (CREATE FORM)
            // ==========================================
            $table->string('nama_lengkap');
            $table->enum('jenis_kelamin', ['L', 'P']);
            $table->string('tempat_lahir');
            $table->date('tanggal_lahir');
            $table->string('hp')->nullable();
            $table->string('email')->nullable();
            
            // Tambahan foto
            $table->string('foto')->nullable();

            // ==========================================
            // FASE 2: TAB A - PROFIL & KELUARGA
            // ==========================================
            $table->string('nik')->nullable()->unique();
            $table->string('agama')->nullable();
            $table->string('kewarganegaraan')->nullable()->default('Indonesia');
            $table->string('nama_ibu_kandung')->nullable();
            $table->string('status_perkawinan')->nullable();
            $table->string('nama_suami_istri')->nullable();
            $table->string('nip_suami_istri')->nullable();
            $table->string('pekerjaan_suami_istri')->nullable();
            $table->string('no_kk')->nullable();

            // ==========================================
            // FASE 2: TAB B - ALAMAT & DOMISILI
            // ==========================================
            $table->string('alamat_jalan')->nullable();
            $table->string('rt', 5)->nullable();
            $table->string('rw', 5)->nullable();
            $table->string('nama_dusun')->nullable();
            $table->string('desa_kelurahan')->nullable();
            $table->string('kecamatan')->nullable();
            $table->string('kode_pos', 10)->nullable();
            $table->string('telepon')->nullable();
            $table->string('lintang')->nullable();
            $table->string('bujur')->nullable();

            // ==========================================
            // FASE 2: TAB C - KEPEGAWAIAN
            // ==========================================
            $table->string('nuptk')->nullable();
            $table->string('status_kepegawaian')->nullable();
            $table->string('jenis_ptk')->nullable();
            $table->string('nip')->nullable()->unique();
            
            $table->foreignId('jabatan_id')->nullable()->constrained('jabatans')->nullOnDelete();
            
            $table->string('sk_cpns')->nullable();
            $table->date('tanggal_cpns')->nullable();
            $table->string('sk_pengangkatan')->nullable();
            $table->date('tmt_pengangkatan')->nullable();
            $table->string('lembaga_pengangkatan')->nullable();
            $table->string('pangkat_golongan')->nullable();
            $table->string('sumber_gaji')->nullable();
            $table->date('tmt_pns')->nullable();
            $table->string('karpeg')->nullable();
            $table->string('karis_karsu')->nullable();
            $table->string('nuks')->nullable();

            // ==========================================
            // FASE 2: TAB D - KOMPETENSI KHUSUS
            // ==========================================
            $table->enum('sudah_lisensi_kepala_sekolah', ['Ya', 'Tidak'])->nullable();
            $table->enum('pernah_diklat_kepengawasan', ['Ya', 'Tidak'])->nullable();
            $table->enum('keahlian_braille', ['Ya', 'Tidak'])->nullable();
            $table->enum('keahlian_bahasa_isyarat', ['Ya', 'Tidak'])->nullable();

            // ==========================================
            // FASE 2: TAB E - FINANSIAL & PAJAK
            // ==========================================
            $table->string('npwp')->nullable();
            $table->string('nama_wajib_pajak')->nullable();
            $table->string('bank')->nullable();
            $table->string('nomor_rekening_bank')->nullable();
            $table->string('rekening_atas_nama')->nullable();

            $table->timestamps();
        });
    }

    public function down(): void
    {
        // 1. Matikan sementara pengecekan relasi (Foreign Key)
        Schema::disableForeignKeyConstraints(); 
        
        // 2. Hapus tabel gurus
        Schema::dropIfExists('gurus');
        
        // 3. Nyalakan kembali pengecekan relasi
        Schema::enableForeignKeyConstraints(); 
    }
};
```

## File: `database/migrations/2026_08_12_182045_create_kategori_beritas_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('kategori_beritas', function (Blueprint $table) {
            $table->id();
            $table->string('nama_kategori');
            $table->string('slug')->unique();
            $table->timestamps();
        });
    }
    public function down(): void {
        Schema::dropIfExists('kategori_beritas');
    }
};
```

## File: `database/migrations/2026_07_15_003246_create_alokasi_waktus_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
{
    Schema::create('alokasi_waktus', function (Blueprint $table) {
        $table->id();
        $table->enum('hari', ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Ahad']);
        $table->enum('kategori', ['Pagi', 'Siang', 'Sore']);
        $table->time('jam_mulai');
        $table->time('jam_selesai');
        $table->boolean('is_mapel')->default(true); // True = Untuk Belajar, False = Istirahat/Upacara
        $table->string('keterangan')->nullable(); // cth: "Jam Ke-1", "Istirahat", "Shalat Dzuhur"
        $table->timestamps();
    });
}

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('alokasi_waktus');
    }
};

```

## File: `database/migrations/2026_06_09_082838_create_kategori_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('kategori_mapels', function (Blueprint $table) {
            $table->id();
            $table->string('nama_kategori'); // Contoh: "Kelompok A (Muatan Nasional)"
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('kategori_mapels');
    }
};
```

## File: `database/migrations/2026_06_10_161700_create_jabatans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('jabatans', function (Blueprint $table) {
            $table->id();
            $table->string('nama_jabatan'); // Contoh: Kepala Madrasah
            $table->integer('urutan_tingkat')->default(99); // Angka 1 paling tinggi
            $table->string('keterangan')->nullable(); // Opsional: deskripsi tugas
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('jabatans');
    }
};
```

## File: `database/migrations/2026_06_14_074909_create_kelas_details_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('kelas_details', function (Blueprint $table) {
            $table->id();
            $table->foreignId('kelas_id')->constrained('kelas')->onDelete('cascade');
            $table->foreignId('gender_id')->constrained('genders')->onDelete('cascade');
            $table->integer('kapasitas'); // Kapasitas dipindah ke sini
            $table->timestamps();
            
            // Mencegah input gender yang sama dua kali di ruang kelas yang sama
            $table->unique(['kelas_id', 'gender_id']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('kelas_details');
    }
};
```

## File: `database/migrations/2026_07_03_150741_add_tahun_ajaran_id_to_ppdbs_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('ppdbs', function (Blueprint $table) {
            $table->foreignId('tahun_ajaran_id')->nullable()->after('no_pendaftaran')->constrained('tahun_ajarans')->onDelete('set null');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('ppdbs', function (Blueprint $table) {
            $table->dropForeign(['tahun_ajaran_id']);
            $table->dropColumn('tahun_ajaran_id');
        });
    }
};
```

## File: `database/migrations/2026_06_10_175238_create_guru_mapels_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('guru_mapels', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->onDelete('cascade');
            $table->foreignId('semester_id')->constrained('semesters')->onDelete('cascade');
            $table->foreignId('guru_id')->constrained('gurus')->onDelete('cascade');
            $table->foreignId('kelas_id')->constrained('kelas')->onDelete('cascade');
            $table->foreignId('mapel_id')->constrained('mapels')->onDelete('cascade');
            $table->unique(['tahun_ajaran_id', 'semester_id', 'kelas_id', 'mapel_id'], 'guru_mapel_unique');

            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('guru_mapels');
    }
};
```

## File: `database/migrations/2026_06_07_091844_create_tahun_ajarans_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('tahun_ajarans', function (Blueprint $table) {
            $table->id();
            $table->string('tahun_ajaran'); // Contoh: 2024/2025
            $table->integer('tahun_ppdb'); // Contoh: 2024
            $table->string('kode'); // Contoh: 24
            $table->enum('status_akademik', ['aktif', 'tidak_aktif', 'mendatang'])->default('mendatang');
            $table->enum('status_ppdb', ['buka', 'tutup', 'persiapan'])->default('persiapan');
            $table->date('tgl_mulai')->nullable();
            $table->date('tgl_akhir')->nullable();
            $table->integer('kuota')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('tahun_ajarans');
    }
};
```

## File: `database/migrations/2026_05_26_013355_create_profil_sekolahs_table.php`
```php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('profil_sekolahs', function (Blueprint $table) {
            $table->id();
            // Identitas
            $table->string('nama_madrasah')->default('MA Al Idrus Lengkong');
            $table->string('nsm_npsn')->nullable();
            $table->year('tahun_berdiri')->nullable();
            $table->string('logo_path')->nullable();
            $table->text('alamat')->nullable();
            $table->string('telepon', 30)->nullable();
            $table->string('email', 100)->nullable();
            $table->string('website', 100)->nullable();
            // Visi Misi
            $table->text('visi')->nullable();
            $table->text('misi')->nullable();
            $table->text('keunggulan')->nullable();
            $table->text('sejarah')->nullable();
            // Data dinamis pakai JSON
            $table->json('prestasi')->nullable();
            $table->json('program_unggulan')->nullable();
            $table->json('fasilitas')->nullable();
            $table->timestamps();
        });
    }
    public function down(): void {
        Schema::dropIfExists('profil_sekolahs');
    }
};
```

## File: `database/migrations/2026_07_22_175215_create_absensis_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('absensis', function (Blueprint $table) {
            $table->id();
            $table->foreignId('siswa_id')->constrained('siswas')->cascadeOnDelete();
            $table->foreignId('guru_mapel_id')->constrained('guru_mapels')->cascadeOnDelete();
            $table->foreignId('tahun_ajaran_id')->constrained('tahun_ajarans')->cascadeOnDelete();
            $table->foreignId('semester_id')->constrained('semesters')->cascadeOnDelete();
            
            $table->date('tanggal');
            $table->enum('status', ['Hadir', 'Sakit', 'Izin', 'Alpa']);
            $table->text('keterangan')->nullable();
            
            $table->timestamps();

            // Mencegah input data ganda untuk siswa, mapel, dan tanggal yang sama
            $table->unique(['siswa_id', 'guru_mapel_id', 'tanggal'], 'unik_absensi_harian');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('absensis');
    }
};
```

## File: `database/migrations/2026_07_12_045349_create_staff_table.php`
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('staffs', function (Blueprint $table) {$table->id();
            // Identitas Dasar
            $table->string('nama_lengkap');
            $table->enum('jenis_kelamin', ['L', 'P']);$table->string('tempat_lahir');
            $table->date('tanggal_lahir');$table->string('agama')->default('Islam')->nullable();
            $table->string('hp')->nullable();$table->string('email')->nullable();
            $table->string('nuptk')->nullable();$table->string('jenis_ptk')->nullable();
            
            // Kepegawaian
            $table->string('sk_pengangkatan')->nullable();
            $table->date('tmt_pengangkatan')->nullable();$table->string('tmt_pengangkatan_hijriyah')->nullable();
            $table->string('nip')->nullable()->unique();$table->string('status_kepegawaian')->nullable();
            $table->foreignId('jabatan_id')->nullable()->constrained('jabatans')->nullOnDelete();$table->string('lembaga_pengangkatan')->nullable();
            $table->string('pangkat_golongan')->nullable();$table->string('sumber_gaji')->nullable();
            $table->string('sk_cpns')->nullable();$table->date('tanggal_cpns')->nullable();
            $table->date('tmt_pns')->nullable();$table->string('karpeg')->nullable();
            $table->string('karis_karsu')->nullable();$table->string('nuks')->nullable();
            
            // Keluarga & Kependudukan
            $table->string('nik')->nullable();$table->string('no_kk')->nullable();
            $table->string('kewarganegaraan')->nullable();$table->string('nama_suami_istri')->nullable();
            $table->string('nip_suami_istri')->nullable();$table->string('pekerjaan_suami_istri')->nullable();
            
            // Domisili
            $table->text('alamat_jalan')->nullable();$table->string('rt')->nullable();
            $table->string('rw')->nullable();$table->string('nama_dusun')->nullable();
            $table->string('desa_kelurahan')->nullable();$table->string('kecamatan')->nullable();
            $table->string('kode_pos')->nullable();$table->string('telepon')->nullable();
            $table->string('lintang')->nullable();$table->string('bujur')->nullable();
            
            // Kompetensi
            $table->string('sudah_lisensi_kepala_sekolah')->nullable();$table->string('pernah_diklat_kepengawasan')->nullable();
            $table->string('keahlian_braille')->nullable();$table->string('keahlian_bahasa_isyarat')->nullable();
            
            // Finansial
            $table->string('npwp')->nullable();
            $table->string('nama_wajib_pajak')->nullable();$table->string('bank')->nullable();
            $table->string('nomor_rekening_bank')->nullable();$table->string('rekening_atas_nama')->nullable();
            
            // File & Dokumen
            $table->string('foto')->nullable();$table->string('file_ijazah')->nullable();
            $table->string('file_ktp')->nullable();$table->string('file_kk')->nullable();
            $table->string('file_npwp')->nullable();$table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('staffs');
    }
};
```

## File: `database/factories/UserFactory.php`
```php
<?php

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
 * @extends Factory<User>
 */
class UserFactory extends Factory
{
    /**
     * The current password being used by the factory.
     */
    protected static ?string $password;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'name' => fake()->name(),
            'email' => fake()->unique()->safeEmail(),
            'email_verified_at' => now(),
            'password' => static::$password ??= Hash::make('password'),
            'remember_token' => Str::random(10),
        ];
    }

    /**
     * Indicate that the model's email address should be unverified.
     */
    public function unverified(): static
    {
        return $this->state(fn (array $attributes) => [
            'email_verified_at' => null,
        ]);
    }
}

```

