Add settings logo upload and brand queue notification emails.
Deploy Ladill Queue / deploy (push) Successful in 55s
Deploy Ladill Queue / deploy (push) Successful in 55s
Let orgs manage logos in settings and render customer-facing mail with company branding. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Services\Comms;
|
||||
|
||||
use App\Mail\ContactMessageMail;
|
||||
use App\Models\Organization;
|
||||
use App\Support\OrganizationBranding;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -13,14 +15,21 @@ use Illuminate\Support\Facades\Mail;
|
||||
*/
|
||||
class EmailService
|
||||
{
|
||||
public function send(string $to, string $subject, string $body, ?string $fromName = null, ?string $replyTo = null): bool
|
||||
public function send(string $to, string $subject, string $body, ?string $fromName = null, ?string $replyTo = null, ?Organization $organization = null): bool
|
||||
{
|
||||
if (! filter_var($to, FILTER_VALIDATE_EMAIL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$logoUrl = null;
|
||||
$companyName = null;
|
||||
if ($organization) {
|
||||
$logoUrl = OrganizationBranding::emailLogoUrl($organization);
|
||||
$companyName = $organization->name;
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo));
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo, $logoUrl, $companyName));
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@@ -47,7 +47,8 @@ class QueueNotificationService
|
||||
public function appointmentReminder(\App\Models\QueueAppointment $appointment): void
|
||||
{
|
||||
$message = "Reminder: your appointment at {$appointment->scheduled_at->format('M j, H:i')} is coming up. Ref: {$appointment->reference}";
|
||||
$this->sendToContact($appointment->customer_phone, $appointment->customer_email, $message);
|
||||
$organization = $appointment->organization;
|
||||
$this->sendToContact($appointment->customer_phone, $appointment->customer_email, $message, $organization);
|
||||
}
|
||||
|
||||
protected function notify(Ticket $ticket, string $event, string $message): void
|
||||
@@ -56,7 +57,8 @@ class QueueNotificationService
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sendToContact($ticket->customer_phone, $ticket->customer_email, $message);
|
||||
$organization = $ticket->organization ?? $ticket->serviceQueue?->organization;
|
||||
$this->sendToContact($ticket->customer_phone, $ticket->customer_email, $message, $organization);
|
||||
|
||||
Log::info('Queue notification sent', [
|
||||
'event' => $event,
|
||||
@@ -64,13 +66,13 @@ class QueueNotificationService
|
||||
]);
|
||||
}
|
||||
|
||||
protected function sendToContact(?string $phone, ?string $email, string $message): void
|
||||
protected function sendToContact(?string $phone, ?string $email, string $message, ?\App\Models\Organization $organization = null): void
|
||||
{
|
||||
if ($phone) {
|
||||
$this->sms->send($phone, $message);
|
||||
}
|
||||
if ($email) {
|
||||
$this->email->send($email, 'Ladill Queue update', $message);
|
||||
$this->email->send($email, 'Ladill Queue update', $message, null, null, $organization);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user