<?php

namespace App\Mail\Subscription;

use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

class RenewalReminder extends BaseSubscriptionMail
{
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Your subscription renews soon',
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'mail.subscription.renewal-reminder',
            with: array_merge($this->commonData(), [
                'renewsAt' => $this->subscription->current_period_ends_at,
                'daysUntilRenewal' => $this->subscription->current_period_ends_at
                    ? max(0, (int) now()->diffInDays($this->subscription->current_period_ends_at, false))
                    : null,
            ]),
        );
    }
}
