<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ProductVariation extends Model
{
    protected $fillable = ['product_id', 'type', 'value', 'price_adjustment', 'stock', 'status'];

    protected $casts = [
        'price_adjustment' => 'decimal:2',
        'status'           => 'boolean',
    ];

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

    public function getLabelAttribute()
    {
        return ucfirst($this->type) . ': ' . $this->value;
    }
}
