<?php

namespace App\Models\Machine;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Product\Product;

class MachineSlot extends Model
{
    use HasFactory;

    protected $fillable = [
        'machine_id',
        'product_id',
        'slot_no',
        'type',
        'max_stock',
        'stock',
        'expiry_date',
        'batch_no',
        'is_active',
    ];

    protected $casts = [
        'price' => 'decimal:2',
        'last_restocked_at' => 'datetime',
        'expiry_date' => 'date:Y-m-d',
    ];

    public function machine()
    {
        return $this->belongsTo(Machine::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}
