<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class PaymentFailedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public $notifiable; //either company or user
    public $subscription; //either Subscription or UserSubscription

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($notifiable, $subscription) {
        $this->notifiable = $notifiable;
        $this->subscription = $subscription;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject("Error al cobrar tu suscripción: Revisa tu método de pago")
            ->markdown('mail.payment.failed', [
                "notifiable" => $this->notifiable,
                "subscription" => $this->subscription
            ]);
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}
