<?php

namespace App\Notifications;

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

class CompleteRegistration extends Notification
{
    use Queueable;
    private $email,$type;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($email,$type)
    {
        $this->email=$email;
        $this->type=$type;
    }

    /**
     * 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)
    {
        $notification = NotificationMessage::where('slug','CompleteRegistration')->first();
        return (new MailMessage)
            ->subject($notification->subject)
            ->greeting($notification->greeting .' ' . $notifiable->name . "!")
            ->line($notification->message)
            ->action($notification->action_button_text, url('/finalize-registration?type='. $this->type .'&id=' . $this->email))
            ->line($notification->end_text);
    }

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