implemented event package addons with filament resource, event-admin purchase path and notifications, showing up in purchase history
This commit is contained in:
66
app/Models/EventPackageAddon.php
Normal file
66
app/Models/EventPackageAddon.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user