<?php

namespace App\Domain\Event\Models;

use App\Domain\Event\Enums\RegistrationStatus;
use App\Domain\Identity\Models\Person;
use App\Domain\Shared\Traits\BelongsToAcademy;
use App\Domain\Shared\Traits\HasUuid;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class EventRegistration extends Model
{
    use BelongsToAcademy, HasUuid, SoftDeletes;

    protected $fillable = [
        'academy_id',
        'event_id',
        'person_id',
        'registration_number',
        'status',
        'form_data',
        'registrant_name',
        'registrant_phone',
        'registrant_email',
        'admin_notes',
        'confirmed_at',
        'cancelled_at',
        'attended_at',
        'ip_address',
    ];

    protected $casts = [
        'status' => RegistrationStatus::class,
        'form_data' => 'array',
        'confirmed_at' => 'datetime',
        'cancelled_at' => 'datetime',
        'attended_at' => 'datetime',
    ];

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

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