<?php

namespace App\Mail;

use App\Invitation;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Queue\SerializesModels;

class InviteApprovedMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public Invitation $invitation
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Your invite for ' . config('app.name') . 'has just been approved',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'mail.invite-approved',
            with: [
                'token' => $this->invitation->invitation_code,
                'invitedDaysSince' => $this->invitation->created_at->diffInDays(now())
            ]
        );
    }

    public function attachments(): array
    {
        return [];
    }
}
