<?php

namespace App\Models;

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

class AccountTypes extends Model
{
    use HasFactory;

    protected $table = "account_types"; // Table name
    protected $fillable = ['name'];     // Mass assignable fields

    // Custom update method
    public static function editAccountType($id, $name)
    {
        return DB::update(
            "UPDATE account_types SET name = ? WHERE id = ?",
            [$name, $id]
        );
    }

    // Custom delete method
    public static function deleteAccountType($id)
    {
        return DB::delete("DELETE FROM account_types WHERE id = ?", [$id]);
    }
}
