<?php

namespace App\Notifications;

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

class BillCreated extends Notification
{
    use Queueable;

    public $bill;
    public $distributorName;
    public $shopName;

    public function __construct($bill, $distributorName, $shopName)
    {
        $this->bill = $bill;
        $this->distributorName = $distributorName;
        $this->shopName = $shopName;
    }

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

    public function toArray(object $notifiable): array
    {
        return [
            'title' => 'New Bill Created',
            'message' => "{$this->distributorName} generated Invoice #{$this->bill->invoice_number} for {$this->shopName}. Total: Rs. {$this->bill->total_amount}",
            'bill_id' => $this->bill->id,
            'amount' => $this->bill->total_amount,
            'type' => 'billing',
            'link' => '/bills'
        ];
    }
}
