<?php

namespace App\Mail;

use App\Models\DividendPayment;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class DividendNotificationMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     */
    public function __construct(
        public DividendPayment $dividend
    ) {}

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: "Dividend Payment - {$this->dividend->getPeriodLabel()} - Meatsoko",
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        return new Content(
            markdown: 'emails.dividend-notification',
            with: [
                'investorName' => $this->dividend->investor->full_name,
                'amount' => number_format($this->dividend->amount, 2),
                'currency' => $this->dividend->currency,
                'period' => $this->dividend->getPeriodLabel(),
                'investmentReference' => $this->dividend->investment->reference,
                'paymentMethod' => $this->dividend->payment_method,
                'paidAt' => $this->dividend->paid_at?->format('F j, Y'),
            ],
        );
    }

    /**
     * Get the attachments for the message.
     */
    public function attachments(): array
    {
        return [];
    }
}
