ctrlpanel/app/Notifications/InvoiceNotification.php
2021-11-30 18:18:15 +01:00

69 lines
1.8 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Models\Payment;
use LaravelDaily\Invoices\Invoice;
class InvoiceNotification extends Notification
{
use Queueable;
/**
* @var invoice
* * @var invoice
* * @var invoice
*/
private $invoice;
private $user;
private $payment;
/**
* Create a new notification instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice, User $user, Payment $payment)
{
$this->invoice = $invoice;
$this->user = $user;
$this->payment = $payment;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->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));
}
}