44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\SupportTicket;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\AnonymousNotifiable;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class NewSupportTicket extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(public readonly SupportTicket $ticket) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return $notifiable instanceof AnonymousNotifiable ? ['mail'] : ['database', 'mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject("New Rsync Studio support request {$this->ticket->reference}")
|
|
->greeting('New support request')
|
|
->line("{$this->ticket->name} <{$this->ticket->email}>")
|
|
->line("Category: {$this->ticket->category}")
|
|
->line("Subject: {$this->ticket->subject}")
|
|
->line($this->ticket->message)
|
|
->action('Open support ticket', route('admin.support.show', $this->ticket));
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'support_ticket_id' => $this->ticket->id,
|
|
'reference' => $this->ticket->reference,
|
|
'subject' => $this->ticket->subject,
|
|
'email' => $this->ticket->email,
|
|
];
|
|
}
|
|
}
|