<?php

namespace App\Models;

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


class Product extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [

        'category_id',
        'product_name',
        'product_code',
        'description',
        'price',
        'discount_price',
        'unit',
        'stock_quantity',
        'product_image',
        'display_order',
        'status'

    ];

    protected $casts = [
        'price'=>'decimal:2',
        'discount_price'=>'decimal:2',
        'status'=>'boolean'
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }
    public function salesOrderItems()
    {
        return $this->hasMany(SalesOrderItem::class);
    }
    public function invoiceItems()
    {
        return $this->hasMany(SalesInvoiceItem::class);
    }
}