<?php

namespace App\Listeners;

use App\Events\PaymentProcessed;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Mail;

class SendPaymentProcessedEmail implements ShouldQueue
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(PaymentProcessed $event)
    {
        $patient = $event->patient;

        Mail::send('emails.process-payment', [], function ($message) use ($patient) {
            $message->to($patient->email, $patient->first_name)
                ->subject('Payment Processed Successfully.');
        });
    }
}
