<?php
namespace Eform\Instruction\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Eform\Instruction\Events\InstructionsAction as InstructionsActionEvent;
use Eform\Instruction\Models\Instructions;

class InstructionsAction extends Notification implements ShouldQueue
{
    use Queueable;

    protected $event;
    protected $instructions;
    protected $action;
    protected $request;

    /**
     * Create a new notification instance.
     *
     * @param InstructionsActionEvent $instructions
     */
    public function __construct(InstructionsActionEvent $instructions)
    {
        $this->action = $event->action;
        $this->instructions = $instructions;
        $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('Instructions Approved - ' . config('app.name'))
            ->view('instruction::instructions.email.action', ['data' => $this->instructions]);
    }

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