<?php

namespace App\Models\Supplier;

use Illuminate\Database\Eloquent\Model;

class SupplierPriceItem extends Model
{
    protected $table = 'supplier_price_items';

    protected $fillable = [
        'price_list_id',
        'title',
        'net_price',
        'sale_price',
        'tax_rate',
        'metadata',
    ];

    protected function casts(): array
    {
        return [
            'net_price' => 'decimal:2',
            'sale_price' => 'decimal:2',
            'tax_rate' => 'decimal:2',
            'metadata' => 'array',
        ];
    }

    public function priceList()
    {
        return $this->belongsTo(SupplierPriceList::class, 'price_list_id');
    }
}
