<?php

namespace App\Notifications;

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

class PaymentCollected extends Notification
{
    use Queueable;

    public $payment;
    public $distributorName;
    public $shopName;
    public $balance;

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

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

    public function toArray(object $notifiable): array
    {
        return [
            'title' => 'Payment Collected',
            'message' => "{$this->distributorName} collected Rs. {$this->payment->amount_paid} from {$this->shopName}. Balance: Rs. {$this->balance}",
            'payment_id' => $this->payment->id,
            'amount' => $this->payment->amount_paid,
            'balance' => $this->balance,
            'type' => 'payment',
            'link' => '/dues'
        ];
    }
}
