-
app/Notifications/NewRegistration.php
Open in GitHubuse Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\URL; class NewRegistration extends Notification { // public function via($notifiable) { return ['mail', 'database']; } public function toMail($notifiable) { $user = $notifiable; if ($user->email_verified_at == '') { $verificationUrl = $this->verificationUrl($notifiable); if (static::$toMailCallback) { return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl); } return (new MailMessage()) ->subject('Thank you for registration!') ->line('Please click the button below to verify your email address.') ->action('Verify Email Address', $verificationUrl) ->line('If you did not create an account, no further action is required.'); } return (new MailMessage()) ->subject('Thank you for registration!') ->line('Thank you for registration at '.app_name().'.') ->action('Vist Application', url('/')) ->line('We are really happy that you started to use '.app_name().'!'); } public function toDatabase($notifiable) { $user = $notifiable; $text = 'Registration Completed! | New registration completed for <strong>'.$user->name.'</strong>'; $url_backend = route('backend.users.profile', $user->id); $url_frontend = route('frontend.users.profile', $user->id); return [ 'title' => 'Registration Completed!', 'module' => 'User', 'type' => 'created', // created, published, viewed, 'icon' => 'fas fa-user', 'text' => $text, 'url_backend' => $url_backend, 'url_frontend' => $url_frontend, ]; } // }
-
app/Listeners/Frontend/UserRegistered/UserRegisteredListener.php
Open in GitHubuse App\Events\Frontend\UserRegistered; use App\Notifications\NewRegistration; use App\Notifications\NewRegistrationFromSocial; use Log; class UserRegisteredListener implements ShouldQueue { public function handle(UserRegistered $event) { $user = $event->user; Log::info('New User Registered as '.$user->name); // Send Email To Registered User if ($user->password == '') { // Register via social do not have passwords try { $user->notify(new NewRegistrationFromSocial()); } catch (\Exception $e) { Log::error('UserRegisteredListener: Email Send Failed.'); Log::error($e); } } else { try { $user->notify(new NewRegistration()); } catch (\Exception $e) { Log::error('UserRegisteredListener: Email Send Failed.'); Log::error($e); } } } }