<?php

namespace App\Models;

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

class Product extends Model
{
    use HasFactory;

    protected $fillable = [
        'barcode',
        'sku',
        'name',
        'category_id',
        'brand_id',
        'size',
        'color',
        'cost_price',
        'selling_price',
        'gst_rate',
        'current_stock',
        'min_stock_alert',
        'image',
        'status',
    ];

    protected $casts = [
        'cost_price' => 'float',
        'selling_price' => 'float',
        'gst_rate' => 'float',
        'current_stock' => 'integer',
        'min_stock_alert' => 'integer',
    ];

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

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

    public function inventoryLogs()
    {
        return $this->hasMany(InventoryLog::class);
    }
}
