<?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 variant (size, colour, etc.) — mirrors Flutter ProductVariantModel
class ProductVariant extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id', 'product_id', 'sku',
        'variant_name', 'attributes_json', 'cost_price', 'sell_price_modifier',
        'stock', 'reorder_point', 'barcode', 'is_active',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'cost_price' => 'float',
        'sell_price_modifier' => 'float',
        'stock' => 'integer',
        'reorder_point' => 'integer',
        'is_active' => 'boolean',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
    ];

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

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