<?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('pelanggarans', function (Blueprint $table) {
            $table->increments('id_pelanggaran');
            $table->integer('id_siswa')->unsigned();
            $table->integer('id_guru')->unsigned();
            $table->integer('id_point_pelanggaran')->unsigned();
            $table->date('tanggal');
            $table->integer('saldo_pelanggaran')->nullable();
            $table->string('keterangan', 255)->nullable();
            $table->foreign('id_siswa')->references('id_siswa')->on('siswas')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('id_guru')->references('id_guru')->on('gurus')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('id_point_pelanggaran')->references('id_point_pelanggaran')->on('point_pelanggarans')->onDelete('cascade')->onUpdate('cascade');
            $table->timestamps();
        });
    }

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