diff --git a/app/Listeners/SendUserRegisteredNotification.php b/app/Listeners/SendUserRegisteredNotification.php index b6595c3d6..bc9b539a4 100644 --- a/app/Listeners/SendUserRegisteredNotification.php +++ b/app/Listeners/SendUserRegisteredNotification.php @@ -3,12 +3,13 @@ namespace App\Listeners; use App\Events\UserSelfRegistered; -use App\Mail\UserRegistered; -use App\Mail\UserRegisteredConfirmation; use App\Models\User; +use App\Notifications\UserRegistered; +use App\Notifications\UserRegisteredConfirmation; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Notification; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; class SendUserRegisteredNotification @@ -21,9 +22,9 @@ public function handle(UserSelfRegistered $event): void $admins = User::where('is_super_admin', true)->get(); try { if ($admins->isNotEmpty()) { - Mail::to($admins)->send(new UserRegistered($user)); + Notification::send($admins, new UserRegistered($user)); } - Mail::to($user)->send(new UserRegisteredConfirmation($user)); + $user->notify(new UserRegisteredConfirmation($user)); } catch (TransportExceptionInterface $ex) { Log::error("Failed to send email to newly registered user $user->email.", $ex); } diff --git a/app/Mail/UserRegistered.php b/app/Mail/UserRegistered.php deleted file mode 100644 index 9d0b0983c..000000000 --- a/app/Mail/UserRegistered.php +++ /dev/null @@ -1,29 +0,0 @@ -markdown('emails.users.registered') - ->subject(__('New user registered: :name', ['name' => $this->user->name])); - } -} diff --git a/app/Mail/UserRegisteredConfirmation.php b/app/Mail/UserRegisteredConfirmation.php deleted file mode 100644 index 451a1daf0..000000000 --- a/app/Mail/UserRegisteredConfirmation.php +++ /dev/null @@ -1,29 +0,0 @@ -markdown('emails.users.registered_confirmation') - ->subject(__('New user account registered at :app_name', ['app_name' => config('app.name')])); - } -} diff --git a/app/Notifications/UserRegistered.php b/app/Notifications/UserRegistered.php new file mode 100644 index 000000000..46168a42e --- /dev/null +++ b/app/Notifications/UserRegistered.php @@ -0,0 +1,48 @@ +subject(__('New user registered: :name', [ + 'name' => $this->user->name, + ])) + ->greeting(__('User registered')) + ->line(__('The user :name (:email) has created a new account.', [ + 'name' => $this->user->name, + 'email' => $this->user->email, + ])) + ->action(__('View User'), route('users.show', $this->user)); + } +} diff --git a/app/Notifications/UserRegisteredConfirmation.php b/app/Notifications/UserRegisteredConfirmation.php new file mode 100644 index 000000000..af716d144 --- /dev/null +++ b/app/Notifications/UserRegisteredConfirmation.php @@ -0,0 +1,51 @@ +subject(__('New user account registered at :app_name', [ + 'app_name' => config('app.name'), + ])) + ->greeting(__('Registration confirmation')) + ->line(__('Dear :name.', [ + 'name' => $this->user->name, + ])) + ->line(__('Thanks for registering an account at :app_name with your e-mail address :email.', [ + 'app_name' => config('app.name'), + 'email' => $this->user->email, + ])) + ->action(__('View your profile'), route('userprofile')); + } +} diff --git a/resources/views/emails/users/registered.blade.php b/resources/views/emails/users/registered.blade.php deleted file mode 100644 index 76cb07a57..000000000 --- a/resources/views/emails/users/registered.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -@component('mail::message') -# {{ __('User registered') }} - -{{ __('The user :name (:email) has created a new account.', [ 'name' => $user->name, 'email' => $user->email ]) }} - -@component('mail::button', ['url' => route('users.show', $user)]) -{{ __('View User') }} -@endcomponent - -{{ __('Thanks,
-:name', [ 'name' => config('app.name') ]) }} -@endcomponent diff --git a/resources/views/emails/users/registered_confirmation.blade.php b/resources/views/emails/users/registered_confirmation.blade.php deleted file mode 100644 index c57f59902..000000000 --- a/resources/views/emails/users/registered_confirmation.blade.php +++ /dev/null @@ -1,14 +0,0 @@ -@component('mail::message') -# {{ __('Registration confirmation') }} - -{{ __('Dear :name.', [ 'name' => $user->name ]) }} - -{{ __('Thanks for registering an account at :app_name with your e-mail address :email.', [ 'app_name' => config('app.name'), 'email' => $user->email ]) }} - -@component('mail::button', ['url' => route('userprofile')]) -{{ __('View your profile') }} -@endcomponent - -{{ __('Thanks,
-:name', [ 'name' => config('app.name') ]) }} -@endcomponent