add controllers, servoices
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user