<?php

namespace App\Mail\Subscription;

use App\Models\Plan;
use App\Models\Subscription;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

class PlanChanged extends BaseSubscriptionMail
{
    public function __construct(
        Subscription $subscription,
        public ?Plan $previousPlan = null,
    ) {
        parent::__construct($subscription);
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Your plan has changed',
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'mail.subscription.plan-changed',
            with: array_merge($this->commonData(), [
                'previousPlanName' => $this->previousPlan?->name,
            ]),
        );
    }
}
