<?php

namespace App\Models;

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

class PriceListName extends Model
{
    use HasFactory;

    protected $table = 'price_list_names';
    protected $fillable = ['code', 'name', 'description'];

    // Edit price list name
    public static function editPriceList($id, $code, $name, $description)
    {
        return DB::update(
            "UPDATE price_list_names SET code = ?, name = ?, description = ? WHERE id = ?",
            [$code, $name, $description, $id]
        );
    }

    // Delete price list name
    public static function deletePriceList($id)
    {
        return DB::delete(
            "DELETE FROM price_list_names WHERE id = ?",
            [$id]
        );
    }
     public function markups(): HasMany
    {
        return $this->hasMany(PriceListingMarkup::class);
    }
}
