Certified/app/Notifications/SubscriptionPaymentDueNotification.php
2026-08-09 16:33:53 +02:00

43 lines
1.4 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Subscription;
use App\Models\SubscriptionInvoice;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class SubscriptionPaymentDueNotification extends Notification
{
use Queueable;
public function __construct(public Subscription $subscription, public SubscriptionInvoice $invoice) {}
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(User $notifiable): MailMessage
{
$message = (new MailMessage)
->subject(__('Invoice for your Certified subscription'))
->greeting(__('Hello :name,', ['name' => $notifiable->name]))
->line(__('A new invoice is ready for your :plan subscription.', ['plan' => $this->subscription->plan->label()]));
if ($this->invoice->due_date) {
$message->line(__('Please pay it before :date to keep your subscription active.', ['date' => $this->invoice->due_date->toFormattedDateString()]));
}
if ($this->invoice->payment_url) {
$message->action(__('Pay invoice'), $this->invoice->payment_url);
}
return $message->line(__("If payment isn't received in time, we'll automatically switch your account back to the Free plan."));
}
}