<?php

namespace App\Models;

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

class Area extends Model
{
    use HasFactory;

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

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

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