<?php

namespace App\Models;

use App\Casts\AmountCast;
use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EventParticipantAddon extends InstancedModel
{
    protected $table = 'event_participant_addons';

    protected $fillable = [
        'tenant',
        'event_id',
        'event_participant_id',
        'addon_key',
        'title',
        'price',
        'flat',
        'days',
        'amount',
    ];

    protected $casts = [
        'flat' => 'boolean',
        'days' => 'integer',
        'price' => AmountCast::class,
        'amount' => AmountCast::class,
    ];

    public function event(): BelongsTo
    {
        return $this->belongsTo(Event::class);
    }

    public function participant(): BelongsTo
    {
        return $this->belongsTo(EventParticipant::class, 'event_participant_id');
    }
}
