- In-app notifications: a bell in the top bar backed by Laravel's database
notification channel, alongside existing e-mail notifications (same
per-trigger toggle drives both; ticket links now correctly point into the
recipient's own area instead of always linking to the client view).
- Drag-and-drop attachments on every upload form, plus inline image
thumbnails in the message thread instead of a plain download link.
- Customer satisfaction (CSAT) rating: clients rate a closed ticket 1-5 stars
with an optional comment; shown read-only to operators, surfaced as a KPI
on the stats dashboard, and linked from the "ticket closed" e-mail.
- Saved queue views: operators can save/apply/delete named filter+sort+
column presets in the ticket queue and mark one as their default.
- Full-text search (MySQL FULLTEXT, portable LIKE fallback) across ticket
subject/body and reply message bodies, now also on the client's own ticket
list.
- Stats CSV export for the currently filtered ticket set.
- Optional BookStack knowledge-base integration (off by default): suggests
articles by category/subcategory while creating a ticket and in a separate
sidebar for operators on an existing ticket (with a copy-link button).
Configurable connection/SSL bypass/search-type filter, plus two
independent per-shelf allow-lists so nothing is ever searched until an
admin opts specific shelves in.
- Closed tickets no longer show in "Moje zgłoszenia"/"Nieprzypisane"/team
queue tabs, only under "Zamknięte" (matching how "Otwarte" already worked).
- Wired up the Admin > About "Wersja" field to config('app.version')/VERSION
in .env instead of a stale hardcoded string.
- Fixed: TicketService::setStatus() now checks a status's stage rather than
the literal key 'closed' to decide whether to fire the "ticket closed"
notification/stop the timer.
- Updated README/ARCHITECTURE/CHANGELOG/install/SECURITY docs and all three
wiki/ role guides for the above; documented a root-vs-www-data file
ownership gotcha in CLAUDE.md (running artisan commands via a plain
`docker exec` can leave root-owned Blade cache files that later break
recompilation for the www-data Apache process).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
2.9 KiB
PHP
81 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\EmailTemplate;
|
|
use App\Models\Ticket;
|
|
use App\Support\Settings;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\AnonymousNotifiable;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class TicketNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* $recipientRole is which area the notified person is being addressed in
|
|
* ('client' or 'operator', mirrors NotificationSetting::$recipient) — a
|
|
* user can hold both roles at once, so this can't be inferred from the
|
|
* notifiable itself; it decides which ticket URL (client vs operator
|
|
* area) both the e-mail link and the in-app notification point to.
|
|
*/
|
|
public function __construct(protected Ticket $ticket, protected int $emailTemplateId, protected string $recipientRole = 'client') {}
|
|
|
|
/**
|
|
* A guest customer with no account is routed anonymously (see
|
|
* TicketService::notify()) and can only ever receive mail — the
|
|
* "database" channel needs a real notifiable model to attach the row to.
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return $notifiable instanceof AnonymousNotifiable ? ['mail'] : ['mail', 'database'];
|
|
}
|
|
|
|
protected function ticketUrl(): string
|
|
{
|
|
return route($this->recipientRole === 'operator' ? 'operator.ticket' : 'client.ticket', $this->ticket);
|
|
}
|
|
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
return [
|
|
'ticket_id' => $this->ticket->id,
|
|
'number' => $this->ticket->number,
|
|
'subject' => $this->ticket->subject,
|
|
'message' => 'Zgłoszenie #'.$this->ticket->number.' — '.$this->ticket->subject,
|
|
'url' => $this->ticketUrl(),
|
|
];
|
|
}
|
|
|
|
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' => $this->ticketUrl(),
|
|
'ocena' => route('client.ticket', $this->ticket).'#csat',
|
|
]) ?? [
|
|
'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']),
|
|
]);
|
|
}
|
|
}
|