<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\DB;

class InventoryCategory extends Model
{
    use HasFactory;

    protected $table = 'inventory_categories'; // actual table name
    protected $fillable = ['group_code', 'name', 'description'];

    // Edit inventory category
    public static function editCategory($id, $group_code, $name, $description)
    {
        return DB::update(
            "UPDATE inventory_categories SET group_code = ?, name = ?, description = ? WHERE id = ?",
            [$group_code, $name, $description, $id]
        );
    }

    // Delete inventory category
    public static function deleteCategory($id)
    {
        return DB::delete(
            "DELETE FROM inventory_categories WHERE id = ?",
            [$id]
        );
    }
}
