<?php

namespace App\Notifications\Api\App;

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

class ReminderStopTripNotification extends Notification
{
    use Queueable;

    protected $via;
    protected $trip_id;
    private $title, $body;

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

        $this->title   = [
            'ar' => trans("The vehicle will stop in :minutes minutes", ['minutes' => $reminder_time], 'ar'),
            'en' => trans("The vehicle will stop in :minutes minutes", ['minutes' => $reminder_time], 'en'),
        ];
        
        $this->body    = [
            'ar' => trans("Warning: The vehicle will stop in :minutes minutes, please recharge your wallet", ['minutes' => $reminder_time], 'ar'),
            'en' => trans("Warning: The vehicle will stop in :minutes minutes, please recharge your wallet", ['minutes' => $reminder_time], 'en'),
        ];
    }

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

    public function toFcm($notifiable)
    {
        return [
            'notify_type'   => 'trip',
            'notify_id'     => $this->trip_id,
            'notify_status' => "reminder_stop",
            'title'         => $this->title[$notifiable->locale ?? 'en'],
            'body'          => $this->body[$notifiable->locale ?? 'en'],
            'sender_data'   => auth('api')->user()?->only(['id', 'full_name', 'avatar']),
        ];
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'notify_type'   => 'trip',
            'notify_id'     => $this->trip_id,
            'notify_status' => "reminder_stop",
            'title'         => $this->title,
            'body'          => $this->body,
            'sender_data'   => auth('api')->user()?->only(['id', 'full_name', 'avatar']),
        ];
    }
}
