<?php

namespace App\Models;

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

class SupplierCategory extends Model
{
    use HasFactory;

    protected $table = "supplier_categories"; // actual table name
    protected $fillable = ['code', 'name', 'description'];

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

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