26 lines
537 B
PHP
26 lines
537 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\PriceType;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Guarded(['id'])]
|
|
class ProductPrice extends Model
|
|
{
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => PriceType::class,
|
|
'price' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
public function variant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductVariant::class, 'variant_id');
|
|
}
|
|
}
|