<?php

namespace App\Models;

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

class SupplierArea extends Model
{
    use HasFactory;

    protected $table = "supplier_areas"; // actual table name
    protected $fillable = ['code', 'name', 'country', 'city', 'specific_location'];

    // Edit supplier area
    public static function editSupplierArea($id, $code, $name, $country, $city, $specific_location)
    {
        return DB::update(
            "UPDATE supplier_areas SET code = ?, name = ?, country = ?, city = ?, specific_location = ? WHERE id = ?",
            [$code, $name, $country, $city, $specific_location, $id]
        );
    }

    // Delete supplier area
    public static function deleteSupplierArea($id)
    {
        return DB::delete("DELETE FROM supplier_areas WHERE id = ?", [$id]);
    }
}
