<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Item extends Model
{
    use HasFactory;

    protected $fillable = [
        'name', 'category', 'unit', 'quantity', 'unit_price', 'description',
    ];

    public static $categories = [
        'gas', 'oil', 'milk', 'water', 'food', 'beverage',
        'cleaning', 'stationery', 'equipment', 'general',
    ];

    public static $units = [
        'pcs', 'liter', 'kg', 'gram', 'bottle', 'box', 'pack', 'dozen',
    ];

    public function getTotalValueAttribute(): float
    {
        return (float) $this->quantity * (float) $this->unit_price;
    }
}
