<?php

namespace App\Notifications;

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

class ServiceOrderAccepted extends Notification
{
    use Queueable;
    private ServiceOrder $order;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(ServiceOrder $order)
    {
        $this->order = $order;
    }

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

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('Your service order has been accepted and worker should start working soon. you can review the progress')
                    ->action('review progress', url('/service/orders/'. $this->order->id))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            "title" => 'Service Order Accepted',
            "description" => 'Your service order has been accepted and worker should start working soon. you can review the progress',
            'title_ar'=> 'تم قبول طلب الخدمة',
            'description_ar'=>'قام مزود الخدمة بالموافقة على طلبك يمكنك الان متابعة التقدم',
            "relative_url" =>'/service/orders/'. $this->order->id,
        ];
    }
}
