<?php

namespace App\Notifications;

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

class PesananDiambilKurir extends Notification
{
    use Queueable;

    private $pesanan;
    private $kurir;

    /**
     * Create a new notification instance.
     */
    public function __construct(Pesanan $pesanan, User $kurir)
    {
        $this->pesanan = $pesanan;
        $this->kurir = $kurir;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'pesanan_id' => $this->pesanan->id,
            'kurir_id' => $this->kurir->id,
            'kurir_nama' => $this->kurir->nama ?? $this->kurir->name,
            'status' => 'dikirim',
            'pesan' => "Pesanan #" . $this->pesanan->id . " telah diambil oleh kurir " . ($this->kurir->nama ?? $this->kurir->name)
        ];
    }
}
