<?php

namespace App\Models;

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

class Lens extends Model
{
    use HasFactory;

    protected $fillable = [
        'vendor_id',
        'category_id',
        'sub_category_id',
        'name',
        'description',
        'price',
        'stock_quantity',
        'low_stock_threshold',
        'size',
        'color',
        'lens_type',
        'images',
        'tryon_image_url',
        'is_active',
    ];

    protected $casts = [
        'price' => 'decimal:2',
        'stock_quantity' => 'integer',
        'low_stock_threshold' => 'integer',
        'images' => 'array',
        'is_active' => 'boolean',
    ];

    public function vendor()
    {
        return $this->belongsTo(User::class, 'vendor_id');
    }

    public function category()
    {
        return $this->belongsTo(LensCategory::class, 'category_id');
    }

    public function subCategory()
    {
        return $this->belongsTo(LensSubCategory::class, 'sub_category_id');
    }
}
