<?php

namespace App\Models;

use App\Models\BaseModel;

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

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

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

    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');
    }
}