<?php

namespace App\Models;

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

class Tax extends Model
{
    use HasFactory;

    protected $table = "taxes"; // actual table name
    protected $fillable = ['description', 'rate'];

    // Edit tax
    public static function editTax($id, $description, $rate)
    {
        return DB::update(
            "UPDATE taxes SET description = ?, rate = ? WHERE id = ?",
            [$description, $rate, $id]
        );
    }

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