check that you correctly bind event and listener in EventServiceProvider and override postRegister method
May 17, 2017
3
Level 1
Code inside event listener not working
Quiz app, laravel 5.2, mac
I am trying to test an event listener when a user registers
after having done php artisan make:auth that sends a welcome email
quizwhiz/app/Http/Controllers/Auth
public function postRegister(Request $request)
{
...
event(new UserRegistered(Auth::user()));
return response()->json();
}
quizwhiz/app/Events/Registration/UserRegistered.php
namespace App\Events\Registration;
use App\Events\Event;
use App\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
public function __construct(User $user)
{
$this->user = $user;
}
quizwhiz/app/Listeners/Registration/UserRegistered/SendWelcomeEmail.php
namespace App\Listeners\Registration\UserRegistered;
use App\Events\Registration\UserRegistered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
...
public function handle(UserRegistered $event)
{
var_dump("Notify".$event->user->name.'that they are getting an email due to registration from the site');
dd("stop");
}
Adding the event seems to have halted the registration When I hit the registration button nothing happens now.
Please or to participate in this conversation.