<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\URL;

class ManagerArtistInviteNotification extends Notification
{
    use Queueable;

    /**
     * User invitation token
     *
     * @var string
     */
    private $token;

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

    /**
     * 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)
    {
        $url = URL::temporarySignedRoute('manager.accept.invite', now()->addDays(2), ['token' => $this->token, 'email' => $notifiable->email]);

        return (new MailMessage)
                ->subject(Auth::user()->name . ' invited you as a Manager | Clapsify')
                ->line('Hope you are having a great day! You have been invited as a manager!')
                ->line(Auth::user()->name . ' has invited you to become their manager. Please accept the invitation below to start managing with their profile.')
                ->action('Accept Invitation', $url)
                ->line('We are happy to have you 🤗');
    }

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