<?php

namespace App\Notifications;

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

class CruiseAdded extends Notification
{
    use Queueable;

    public $cruise;

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

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


    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        $user = auth()->user();
        return [
            'sender'=>[
                'name' => $user->name,
                'image'=> $user->image??'user2-160x160.jpg'
            ],
            'message'=>trans('messages.cruise_notif',['name'=>$this->cruise->name]),
            'time' => $this->cruise->created_at->format('h:i')
        ];
    }
}
