<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Product extends Model
{
    use HasFactory, SoftDeletes;

    protected $primaryKey = 'product_id';

    protected $fillable = [
        'product_code',
        'category_id',
        'brand_id',
        'style_id',
        'size_id',
        'color_id',
        'threshold',
        'product_quantity',
        'product_manual_quantity',
        'product_mrp',
        'product_price',
        'active_status',
        'tax'
    ];

    protected $casts = [
        'active_status' => 'int',
        'product_mrp' => 'decimal:2',
        'product_price' => 'decimal:2',
    ];

    public function category()
    {
        return $this->belongsTo(Category::class, 'category_id', 'category_id');
    }

    public function brand()
    {
        return $this->belongsTo(Brand::class, 'brand_id', 'brand_id');
    }

    public function style()
    {
        return $this->belongsTo(Style::class, 'style_id', 'style_id');
    }

    public function size()
    {
        return $this->belongsTo(Size::class, 'size_id', 'size_id');
    }

    public function color()
    {
        return $this->belongsTo(Color::class, 'color_id', 'color_id');
    }
}
