Skip to content

Instantly share code, notes, and snippets.

@fulopattila122
Created October 8, 2021 10:24
Show Gist options
  • Save fulopattila122/5e965fdbd6df813566b4ff1f0fa4be72 to your computer and use it in GitHub Desktop.
Save fulopattila122/5e965fdbd6df813566b4ff1f0fa4be72 to your computer and use it in GitHub Desktop.
SendOrderPaidNotification
<?php
namespace App\Modules\Membership\Notifications;
use App\Modules\Order\Models\Order;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class OrderPaid extends Notification
{
/** @var Order */
protected $order;
public function __construct(Order $order)
{
$this->order = $order;
}
public function via()
{
return ['mail'];
}
public function toMail($notifiable)
{
$message = new MailMessage();
$invoiceLink = helper('payment')->getInvoicePdfUrl($this->order->payment->getInvoice());
$accountLink = route('membership.account.order.show', $this->order);
$message->viewData = [
'legal' => true,
'payment' => $this->order->payment
];
return $message
->to($notifiable->email)
->subject("Payment accepted for your order no. #{$this->order->number}")
->greeting("Hi, {$this->order->billingAddress->name}")
->line("
Payment was accepted.<br>
Invoice nr. {$this->order->payment->getInvoice()->external_id} has been issued and can be accessed in your account.
")
->line("<a href='$invoiceLink'>Download Invoice.</a>")
->line("See <a href='$accountLink'>order detauks</a> and follow status in your account.");
}
}
<?php
namespace App\Modules\Membership\Listeners;
use App\Modules\Membership\Notifications\OrderPaid;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendOrderPaidNotification implements ShouldQueue
{
public function handle($event)
{
$event->getOrder()->user->notify(new OrderPaid($event->getOrder()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment