<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Concerns\BelongsToBusiness;

class Product extends Model
{
    use HasFactory, SoftDeletes, BelongsToBusiness;

    protected $fillable = [
        'business_id',
        'owner_id',
        'product_code',
        'product_name',
        'product_type_id',
        'contact_id',
        'unit_id',
        'price',
        'stock_quantity',
        'tax',
        'discount',
        'product_category_id',
        'images',
        'description',
        'status',
        'is_draft',
    ];

    protected $casts = ['images'=>'array','is_draft'=>'boolean'];
    public function owner() { return $this->belongsTo(User::class, 'owner_id'); }
    public function priceBookItems() { return $this->hasMany(PriceBookItem::class); }
    public function inventoryReservations() { return $this->hasMany(InventoryReservation::class); }
}
