ctrlpanel/app/Notifications/InvoiceNotification.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2021-11-27 01:47:36 +00:00
<?php
namespace App\Notifications;
2021-11-30 17:18:15 +00:00
use App\Models\User;
2021-11-27 01:47:36 +00:00
use Illuminate\Bus\Queueable;
2021-11-30 13:09:13 +00:00
use Illuminate\Notifications\Messages\MailMessage;
2021-11-27 01:47:36 +00:00
use Illuminate\Notifications\Notification;
2021-11-30 17:18:15 +00:00
use App\Models\Payment;
2021-11-27 01:47:36 +00:00
use LaravelDaily\Invoices\Invoice;
class InvoiceNotification extends Notification
{
use Queueable;
/**
* @var invoice
2021-11-30 17:18:15 +00:00
* * @var invoice
* * @var invoice
2021-11-27 01:47:36 +00:00
*/
private $invoice;
2021-11-30 17:18:15 +00:00
private $user;
private $payment;
2021-11-27 01:47:36 +00:00
/**
* Create a new notification instance.
*
* @param Invoice $invoice
*/
2021-11-30 17:18:15 +00:00
public function __construct(Invoice $invoice, User $user, Payment $payment)
2021-11-27 01:47:36 +00:00
{
$this->invoice = $invoice;
2021-11-30 17:18:15 +00:00
$this->user = $user;
$this->payment = $payment;
2021-11-27 01:47:36 +00:00
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
2021-11-30 13:09:13 +00:00
return ['mail'];
2021-11-27 01:47:36 +00:00
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
2021-11-30 13:09:13 +00:00
* @return MailMessage
2021-11-27 01:47:36 +00:00
*/
2021-11-30 13:09:13 +00:00
public function toMail($notifiable)
2021-11-27 01:47:36 +00:00
{
2021-11-30 13:09:13 +00:00
return (new MailMessage)
2021-11-30 17:18:15 +00:00
->subject('Your Payment was successful!')
->greeting('Hello,')
->line("Your payment was processes!.")
->line('Status: '.$this->payment->status)
->line('Price: '.$this->payment->formatToCurrency($this->payment->total_price))
->line('Type: '.$this->payment->type)
->line('Amount: '.$this->payment->amount)
->line('Balance: '.$this->user->credits)
->line('User ID: '.$this->payment->user_id)
->attach(storage_path('app/invoice/'.$this->user->id.'/'.now()->format('Y').'/'.$this->invoice->filename));
2021-11-27 01:47:36 +00:00
}
}