<?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('mahasiswa', function (Blueprint $table) {
            // Data Pribadi
            $table->string('tempat_lahir')->nullable()->after('nama');
            $table->date('tanggal_lahir')->nullable()->after('tempat_lahir');
            $table->enum('agama', ['Islam', 'Kristen', 'Katolik', 'Hindu', 'Buddha', 'Konghucu'])->nullable()->after('tanggal_lahir');
            $table->enum('jenis_kelamin', ['Laki-laki', 'Perempuan'])->nullable()->after('agama');

            // NIK & Kontak
            $table->string('nik', 20)->nullable()->unique()->after('jenis_kelamin');
            $table->string('no_wa', 20)->nullable()->after('nik');
            $table->string('no_darurat', 20)->nullable()->after('no_wa');
            $table->string('email')->nullable()->after('no_darurat');
            $table->text('alamat')->nullable()->after('email');

            // Data Orang Tua
            $table->string('nama_ayah')->nullable()->after('alamat');
            $table->string('nama_ibu')->nullable()->after('nama_ayah');

            // Data Akademik
            $table->string('no_seleksi')->nullable()->unique()->after('prodi_id');
            $table->enum('kelompok', ['SMA', 'D3', 'S1'])->nullable()->after('no_seleksi');
            $table->enum('status_masuk', ['Baru', 'Pindahan'])->nullable()->after('kelompok');
            $table->string('tahun_ajaran')->nullable()->after('angkatan');
            $table->enum('waktu_kuliah', [
                'Reguler Pagi',
                'Reguler Malam/Sore',
                'Kelas Weekend',
                'E-learning/Online'
            ])->nullable()->after('tahun_ajaran');

            // Ukuran Jaket
            $table->enum('ukuran_jaket', ['S', 'M', 'L', 'XL', 'XXL', 'XXXL'])->nullable()->after('waktu_kuliah');

            // Sumber Informasi
            $table->enum('sumber_informasi', [
                'Facebook',
                'Instagram',
                'Tiktok',
                'Teman/Keluarga',
                'Brosur',
                'Google',
                'RAP (Recruitment Affiliate Program)',
                'BDC',
                'Datang Langsung',
                'Subdomain'
            ])->nullable()->after('ukuran_jaket');

            $table->string('nama_rap')->nullable()->after('sumber_informasi');
        });
    }

    public function down()
    {
        Schema::table('mahasiswa', function (Blueprint $table) {
            $table->dropColumn([
                'tempat_lahir',
                'tanggal_lahir',
                'agama',
                'jenis_kelamin',
                'nik',
                'no_wa',
                'no_darurat',
                'email',
                'alamat',
                'nama_ayah',
                'nama_ibu',
                'no_seleksi',
                'kelompok',
                'status_masuk',
                'tahun_ajaran',
                'waktu_kuliah',
                'ukuran_jaket',
                'sumber_informasi',
                'nama_rap',
            ]);
        });
    }
};
