ctrlpanel/app/Notifications/InvoiceNotification.php

71 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2021-11-27 01:47:36 +00:00
<?php
namespace App\Notifications;
2021-11-30 17:40:56 +00:00
use App\Models\Payment;
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;
use LaravelDaily\Invoices\Invoice;
class InvoiceNotification extends Notification
{
use Queueable;
2021-11-30 17:40:56 +00:00
2021-11-27 01:47:36 +00:00
/**
* @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;
2021-11-30 17:18:15 +00:00
private $payment;
2021-11-27 01:47:36 +00:00
/**
* Create a new notification instance.
*
* @param Invoice $invoice
2021-11-27 01:47:36 +00:00
*/
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
2021-11-27 01:47:36 +00:00
* @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-12-16 18:38:25 +00:00
->subject(__('Your Payment was successful!'))
->greeting(__('Hello').',')
->line(__('Your payment was processed successfully!'))
->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').': '.number_format($this->user->credits, 2))
->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
}
}