2020-05-13 21:47:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Auth\Events\Registered;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
use App\User;
|
|
|
|
use App\Notifications\NewUser;
|
|
|
|
|
2020-05-13 21:47:51 +00:00
|
|
|
class OnUserRegistration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create the event listener.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
|
|
|
* @param Registered $event
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(Registered $event)
|
|
|
|
{
|
|
|
|
// TODO: Send push notification to online admins via browser (w/ pusher)
|
|
|
|
Log::info('User ' . $event->user->name . ' has just registered for an account.');
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
foreach(User::all() as $user)
|
|
|
|
{
|
|
|
|
if ($user->hasRole('admin'))
|
|
|
|
{
|
|
|
|
$user->notify(new NewUser($event->user));
|
|
|
|
}
|
|
|
|
}
|
2020-05-13 21:47:51 +00:00
|
|
|
}
|
|
|
|
}
|