<?php

namespace App\Models;

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

class modelTax extends Model
{
    public static function selectTax($code)
    {

        return DB::select("SELECT * FROM `tax` where `Code`='$code'");
    }
    public static function selectTaxByCode($code,$name)
    {

        return DB::select("SELECT * FROM `tax` where `Code`='$code' and `Name`='$name'");
    }
    public static function saveTax($code,$name,$rate)
    {
        return DB::insert("INSERT INTO `tax` ( `Code`, `Name`, `Rate`) VALUES (?, ?,?)", [$code, $name,$rate] );
    }

    public static function editTax($id,$code,$name,$rate)
    {
        return DB::insert("UPDATE  `tax` set  `Name`=? , `Rate`=? where Code=? and ID=?", [$name, $rate,$code,$id] );
    }

    public static function deleteTax($id,$code)
    {
        return DB::insert("DELETE FROM   `tax`  where Code=? and ID=?", [$code,$id] );
    }
}
