<?php

namespace App\Models;

use App\Models\BaseModel;

class InventoryItem extends BaseModel
{
    protected $table = 'inventory_items';

    // ✅ legacy: useTimestamps = true
    public $timestamps = true;

    protected $fillable = [
        'type',
        'category_id',
        'name',
        'description',
        'quantity',
        'unit',
        'condition',
        'isbn',
        'edition',
        'sku',
        'notes',
        'semester',
        'school_year',
        'updated_by',
        'good_qty',
        'needs_repair_qty',
        'need_replace_qty',
        'cannot_find_qty',
    ];

    protected $casts = [
        'category_id'        => 'integer',
        'quantity'           => 'integer',
        'updated_by'         => 'integer',

        'good_qty'           => 'integer',
        'needs_repair_qty'   => 'integer',
        'need_replace_qty'   => 'integer',
        'cannot_find_qty'    => 'integer',
    ];

    /* Optional relationships */
    public function category()
    {
        return $this->belongsTo(InventoryCategory::class, 'category_id');
    }
}