<?php
namespace Bixo\Payment\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Bixo\Payment\Events\InvoiceAction as InvoiceActionEvent;
use Bixo\Payment\Models\Invoice;

class InvoiceAction extends Notification implements ShouldQueue
{
    use Queueable;

    protected $event;
    protected $invoice;
    protected $action;
    protected $request;

    /**
     * Create a new notification instance.
     *
     * @param InvoiceActionEvent $invoice
     */
    public function __construct(InvoiceActionEvent $invoice)
    {
        $this->action = $event->action;
        $this->invoice = $invoice;
        $this->request = $event->request;
        $this->event = $event;

    }

    /**
     * Get the mail representation of the notification.
     *
     * @param mixed $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('Invoice Approved - ' . config('app.name'))
            ->view('payment::invoice.email.action', ['data' => $this->invoice]);
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param object $notifiable
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }
}