Files
alrahma_sunday_school_api/app/Services/Users/UserEventService.php
T
2026-06-09 01:03:53 -04:00

32 lines
939 B
PHP

<?php
namespace App\Services\Users;
use App\Services\EmailService;
use Illuminate\Support\Facades\Log;
class UserEventService
{
public function __construct(private EmailService $emailService)
{
}
public function handleNewAccountAdded(array $userData): bool
{
$email = (string) ($userData['email'] ?? '');
if ($email === '') {
Log::warning('UserEventService: missing email for welcome message.');
return false;
}
$name = trim((string) (($userData['firstname'] ?? '') . ' ' . ($userData['lastname'] ?? '')));
$safeName = e($name !== '' ? $name : 'there');
$subject = 'Welcome to Al Rahma Sunday School!';
$message = '<p>Hello ' . $safeName . ',</p>'
. '<p>Your account has been created. Welcome to Al Rahma Sunday School.</p>';
return $this->emailService->send($email, $subject, $message, 'registration');
}
}