67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class EventPackageAddon extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'event_package_id',
|
|
'event_id',
|
|
'tenant_id',
|
|
'addon_key',
|
|
'quantity',
|
|
'extra_photos',
|
|
'extra_guests',
|
|
'extra_gallery_days',
|
|
'price_id',
|
|
'checkout_id',
|
|
'transaction_id',
|
|
'status',
|
|
'amount',
|
|
'currency',
|
|
'metadata',
|
|
'receipt_payload',
|
|
'error',
|
|
'purchased_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'metadata' => 'array',
|
|
'receipt_payload' => 'array',
|
|
'purchased_at' => 'datetime',
|
|
];
|
|
|
|
protected function increments(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => [
|
|
'extra_photos' => (int) ($this->extra_photos ?? 0),
|
|
'extra_guests' => (int) ($this->extra_guests ?? 0),
|
|
'extra_gallery_days' => (int) ($this->extra_gallery_days ?? 0),
|
|
],
|
|
);
|
|
}
|
|
|
|
public function eventPackage(): BelongsTo
|
|
{
|
|
return $this->belongsTo(EventPackage::class);
|
|
}
|
|
|
|
public function event(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Event::class);
|
|
}
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
}
|