Email integration: IMAP polling via webklex/php-imap (M365/Zoho/MIAB
compatible), TicketEmailProcessor with 3-strategy ticket matching
(In-Reply-To, References, subject line [EZSCALE-{id}]), signature and
quote stripping, scheduled command every 2min.
Outbound: 4 notification classes (TicketCreated, CustomerReply,
StaffReply, StatusChanged) with email threading headers via
withSymfonyMessage(). Staff replies set Reply-To: support@ezscale.cloud.
Frontend: ticket reference chips on all pages, "Via Email" badges on
email-originated replies. 12 new tests (163 total, 816 assertions).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\SupportTicket;
|
|
use App\Models\TicketReply;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class TicketCustomerReplyNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public SupportTicket $ticket,
|
|
public TicketReply $reply,
|
|
) {}
|
|
|
|
/** @return array<int, string> */
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail', 'database'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$reference = $this->ticket->ticket_reference ?? '[EZSCALE-'.$this->ticket->id.']';
|
|
$adminUrl = 'https://'.config('app.domains.admin').'/tickets/'.$this->ticket->id;
|
|
|
|
return (new MailMessage)
|
|
->subject('Re: '.$this->ticket->subject.' '.$reference)
|
|
->greeting("Hello {$notifiable->name}!")
|
|
->line('A customer has replied to a support ticket.')
|
|
->line('**Ticket:** '.$this->ticket->subject)
|
|
->line('**Customer:** '.($this->reply->user?->name ?? $this->reply->from_email ?? 'Unknown'))
|
|
->line($this->reply->body)
|
|
->action('View Ticket', $adminUrl)
|
|
->line('Please review and respond at your earliest convenience.');
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'ticket_customer_reply',
|
|
'ticket_id' => $this->ticket->id,
|
|
'reply_id' => $this->reply->id,
|
|
'subject' => $this->ticket->subject,
|
|
'message' => 'Customer replied to ticket: '.$this->ticket->subject,
|
|
];
|
|
}
|
|
}
|