👁 查看:ProductVariation.php
路径:/home/boguraj1/.trash/app/Models/ProductVariation.php
大小:531 B · 修改:2026-07-23 16:13:46 · 权限:0644 · 可写
<?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;
    }
}