<?php

namespace App\Mail;

use App\Models\Loan;
use App\Models\LoanRepayment;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class LoanRepaymentReceived extends Mailable
{
    use Queueable, SerializesModels;

    public Loan $loan;
    public LoanRepayment $repayment;

    /**
     * Create a new message instance.
     */
    public function __construct(Loan $loan, LoanRepayment $repayment)
    {
        $this->loan = $loan;
        $this->repayment = $repayment;
    }

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Loan Repayment Received - ' . $this->loan->loan_number,
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        return new Content(
            view: 'emails.loan-repayment-received',
            with: [
                'loan' => $this->loan,
                'client' => $this->loan->client,
                'repayment' => $this->repayment,
            ],
        );
    }

    /**
     * Get the attachments for the message.
     *
     * @return array<int, \Illuminate\Mail\Mailables\Attachment>
     */
    public function attachments(): array
    {
        return [];
    }
}
