<?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('journals', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->foreignId('subject_id')->constrained()->onDelete('cascade'); // Relasi Mapel
            $table->date('date');
            $table->string('class'); // Kelas yg diajar saat itu
            $table->string('period'); // Jam Ke
            $table->integer('meeting_sequence'); // Pertemuan Ke
            
            $table->json('topics')->nullable(); // Checkbox Materi (JSON Array)
            $table->json('student_attendance')->nullable(); // ID Siswa Hadir (JSON Array)
            
            $table->text('notes')->nullable();
            $table->string('photo')->nullable(); // Foto dokumentasi
            $table->timestamps();
        });
    }

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