This commit is contained in:
2026-07-21 23:39:19 +02:00
commit b33b217bdb
217 changed files with 32076 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Notifications;
use App\Models\EmailTemplate;
use App\Models\Ticket;
use App\Support\Settings;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TicketNotification extends Notification
{
use Queueable;
public function __construct(protected Ticket $ticket, protected int $emailTemplateId) {}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$template = EmailTemplate::query()->find($this->emailTemplateId);
$firstName = trim(explode(' ', $this->ticket->name)[0] ?? $this->ticket->name);
$rendered = $template?->render([
'numer' => $this->ticket->number,
'imie' => $firstName,
'temat' => $this->ticket->subject,
'status' => $this->ticket->statusLabel(),
'kategoria' => $this->ticket->categoryLabel(),
'priorytet' => $this->ticket->priorityLabel(),
'zespol' => $this->ticket->team?->name ?? 'Brak',
'operator' => $this->ticket->assignee?->name ?? 'Nieprzypisane',
'link' => route('client.ticket', $this->ticket),
]) ?? [
'subject' => 'Zgłoszenie #'.$this->ticket->number,
'body' => $this->ticket->subject,
];
return (new MailMessage)
->subject($rendered['subject'])
->view('emails.ticket-notification', [
'html' => Settings::renderEmailLayout($rendered['body']),
]);
}
}