<?php

namespace App\Notifications;

class ApplicationAdmitted extends ApplicationNotification
{
    protected function subject(): string
    {
        return 'Congratulations - you have been admitted to '.setting('university_name', 'King Ceasor University');
    }

    protected function heading(): string
    {
        return 'Congratulations, '.$this->application->applicant->first_name.'!';
    }

    protected function lines(): array
    {
        $record = $this->application->admissionRecord;
        $programme = $record?->programme?->name ?? $this->application->programme()?->name;

        return array_values(array_filter([
            "You have been offered a place on {$programme}.",
            $record ? "Your admission number is {$record->admission_number}." : null,
            'Your admission letter and joining instructions are available in your portal.',
            $record?->acceptance_deadline
                ? 'Please confirm your acceptance by '.$record->acceptance_deadline->format('j F Y').'.'
                : null,
        ]));
    }

    protected function actionLabel(): ?string
    {
        return 'View Admission Letter';
    }

    public function toSms(): ?string
    {
        $record = $this->application->admissionRecord;

        return sprintf(
            'KCU: Congratulations! You have been admitted. Admission no %s. Download your letter from your portal.',
            $record?->admission_number ?? $this->application->application_number,
        );
    }
}
