<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class AwbAssigned extends Notification
{
    use Queueable;

    public $request;
    public $type; // 'Import' or 'Export'
    public $awb;

    public function __construct($request, $type, $awb)
    {
        $this->request = $request;
        $this->type = $type;
        $this->awb = $awb;
    }

    public function via($notifiable)
    {
        return ['database'];
    }

    public function toArray($notifiable)
    {
        return [
            'title' => "AWB Assigned",
            'message' => "AWB {$this->awb} has been assigned to your {$this->type} request #{$this->request->id}.",
            'url' => route(strtolower($this->type) . '_requests.show', $this->request->id),
            'type' => 'success',
        ];
    }
}
