<?php

namespace App\Notifications;

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

class SubscriptionStatusChangedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(public Subscription $subscription)
    {
    }

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

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject('Abonelik Durumu Güncellendi: '.$this->subscription->reference_no)
            ->line("{$this->subscription->customer_name} adlı abonelik durumu \"{$this->subscription->status->label()}\" olarak güncellendi.");
    }

    public function toArray(object $notifiable): array
    {
        return [
            'category' => 'sistem',
            'subscription_id' => $this->subscription->id,
            'title' => 'Abonelik Durumu Değişti',
            'message' => "{$this->subscription->reference_no} → {$this->subscription->status->label()}",
        ];
    }
}
