<?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('books', function (Blueprint $table) {
            $table->id();
            $table->string('judul');
            $table->string('penulis');
            $table->string('cover')->nullable();
            $table->string('kode_buku')->unique();
            $table->foreignId('category_id')->constrained('categories')->onDelete('cascade');
            $table->integer('tahun');
            $table->string('status')->default('Tersedia');
            $table->boolean('is_new')->default(false);
            $table->json('tipe_akses'); // ['online', 'offline']
            $table->timestamps();
        });
    }

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