Add some event listeners and experiment with browser testing

This commit is contained in:
Nabeel Shahzad
2017-12-22 12:00:57 -06:00
parent 7fbe2f5e30
commit 74316218bc
12 changed files with 369 additions and 65 deletions

View File

@@ -0,0 +1,34 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: nabeelshahzad
* Date: 12/22/17
* Time: 11:44 AM
*/
namespace App\Listeners;
use Log;
use \App\Events\UserRegistered;
/**
* Handle sending emails on different events
* @package App\Listeners
*/
class EmailEventListener
{
public function subscribe($events)
{
$events->listen(
UserRegistered::class,
'App\Listeners\EmailEventListener@onUserRegister'
);
}
public function onUserRegister(UserRegistered $event)
{
Log::info($event->user->toArray());
}
}

View File

@@ -2,9 +2,9 @@
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
@@ -18,6 +18,10 @@ class EventServiceProvider extends ServiceProvider
],*/
];
protected $subscribe = [
'App\Listeners\EmailEventListener',
];
/**
* Register any events for your application.
*
@@ -26,7 +30,5 @@ class EventServiceProvider extends ServiceProvider
public function boot()
{
parent::boot();
//
}
}

View File

@@ -49,7 +49,6 @@ class UserService extends BaseService
# Let's check their rank
$this->calculatePilotRank($user);
# TODO: Send out an email
event(new UserRegistered($user));
return $user;