listen( UserRegistered::class, 'App\Listeners\EmailEventListener@onUserRegister' ); } /** * Send an email when the user registered * @param UserRegistered $event */ public function onUserRegister(UserRegistered $event) { Log::info('onUserRegister: ' . $event->user->pilot_id . ' is ' . PilotState::label($event->user->state) . ', sending active email'); if($event->user->state === PilotState::ACTIVE) { Mail::to($event->user->email)->send(new \App\Mail\UserRegistered($event->user)); } else if($event->user->state === PilotState::PENDING) { Mail::to($event->user->email)->send(new \App\Mail\UserPending($event->user)); } } }