<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

// [INTEGRATION] Product batch/lot with expiry — mirrors Flutter ProductBatchModel
class ProductBatch extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id', 'product_id', 'batch_number',
        'expiry_date', 'manufacture_date', 'quantity', 'cost_price',
        'supplier_id', 'purchase_id', 'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'quantity' => 'integer',
        'cost_price' => 'float',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
        'expiry_date' => 'date',
        'manufacture_date' => 'date',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

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