Files
Tarnax/appstore/website/app/Notifications/AccountUpdate.php
T

32 lines
948 B
PHP

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\DB;
class AccountUpdate extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(public string $subject, public string $message, public string $url, public ?string $template = null)
{
$this->afterCommit();
}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$template = $this->template ? DB::table('email_templates')->where('slug', $this->template)->first() : null;
return (new MailMessage)->subject($template?->subject ?? $this->subject)->line($template?->body ?? $this->message)->action('Open your account', $this->url);
}
}