<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ShopProductStock extends Model
{
    protected $fillable = [
        'shop_product_id',
        'shop_id',
        'quantity',
        'low_stock_threshold',
    ];

    protected $casts = [
        'quantity' => 'decimal:2',
        'low_stock_threshold' => 'decimal:2',
    ];

    public function shopProduct(): BelongsTo
    {
        return $this->belongsTo(ShopProduct::class);
    }

    public function shop(): BelongsTo
    {
        return $this->belongsTo(Account::class, 'shop_id')->where('model_type', 'shop');
    }
}
