<?php

namespace App\Models;

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

class ShopProduct extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'code',
        'account_id',
        'shop_id',
        'local_id',
        'name',
        'shop_product_sku',
        'shop_product_barcode',
        'is_active',
    ];
    
    protected $casts = [
        'is_active' => 'boolean',
    ];

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

    public function prices(): HasMany
    {
        return $this->hasMany(ShopProductPrice::class);
    }

    public function stocks(): HasMany
    {
        return $this->hasMany(ShopProductStock::class);
    }
}
