<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class AdmissionRecord extends Model
{
    use HasFactory;

    protected $fillable = [
        'application_id', 'admission_number', 'programme_id', 'intake_id',
        'study_mode', 'campus', 'conditions', 'reporting_date', 'acceptance_deadline',
        'verification_code', 'admitted_at', 'admitted_by', 'status', 'accepted_at',
    ];

    protected function casts(): array
    {
        return [
            'reporting_date' => 'date',
            'acceptance_deadline' => 'date',
            'admitted_at' => 'datetime',
            'accepted_at' => 'datetime',
        ];
    }

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

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

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

    public function admittedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'admitted_by');
    }
}
