<?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('riwayat_pengiriman_wa', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('siswa_id')->nullable();
            $table->string('nama_siswa')->nullable();
            $table->string('no_wa');
            $table->enum('jenis_pesan', ['Tagihan Tunggakan', 'Tagihan Tunggakan massal', 'Rekap Pembayaran']);
            $table->enum('status', ['berhasil', 'gagal']);
            $table->text('keterangan')->nullable();
            $table->unsignedBigInteger('dikirim_oleh')->nullable();
            $table->timestamps();

            $table->foreign('siswa_id')->references('id')->on('siswa')->nullOnDelete();
            $table->foreign('dikirim_oleh')->references('id')->on('users')->nullOnDelete();
        });
    }

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