<?php

namespace App\Notifications;

use App\Models\JobApplication;
use App\Models\JobPosting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class NewApplicationAdminNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public JobApplication $application,
        public JobPosting $job
    ) {
    }

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $adminUrl = url('/admin/basvurular/' . $this->application->id);

        return (new MailMessage)
            ->subject('Yeni Başvuru: ' . $this->job->title)
            ->greeting('Merhaba,')
            ->line('**' . $this->job->title . '** pozisyonuna yeni bir başvuru geldi.')
            ->line('**Başvuran:** ' . $this->application->full_name)
            ->line('**E-posta:** ' . $this->application->email)
            ->line('**Telefon:** ' . $this->application->phone)
            ->action('Başvuruyu İncele', $adminUrl)
            ->salutation('Markamama Kariyer Sistemi');
    }
}