<?php

namespace App\Modules\Admin\Tenancy\Notifications;

use Carbon\CarbonInterface;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class TrialExpiringSoonNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly int $daysLeft,
        public readonly CarbonInterface $trialEndsAt,
    ) {}

    /**
     * @return list<string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'trial_expiring',
            'days_left' => $this->daysLeft,
            'trial_ends_at' => $this->trialEndsAt->toIso8601String(),
            'title' => __('plan_limits.notifications.trial_title'),
            'body' => __('plan_limits.notifications.trial_body', [
                'days' => $this->daysLeft,
            ]),
            'upgrade_url' => route('dashboard.index'),
        ];
    }
}
