<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Book extends Model
{
    protected $fillable = [
        'judul', 'penulis', 'cover', 'kode_buku', 
        'category_id', 'tahun', 'status', 'is_new', 'tipe_akses', 'file_pdf'
    ];

    protected $casts = [
        'tipe_akses' => 'array',
        'is_new' => 'boolean',
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function loans()
    {
        return $this->hasMany(Loan::class);
    }
}
