refactor(listeners): remove big n+1 query in user notifications
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
parent
5ff1b4532a
commit
2901f76a11
@ -49,10 +49,11 @@ class OnUserRegistration
|
|||||||
// TODO: Send push notification to online admins via browser (w/ pusher)
|
// TODO: Send push notification to online admins via browser (w/ pusher)
|
||||||
Log::info('User '.$event->user->name.' has just registered for an account.');
|
Log::info('User '.$event->user->name.' has just registered for an account.');
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
User::whereHas('roles', function ($q) {
|
||||||
if ($user->hasRole('admin')) {
|
$q->where('name', 'admin');
|
||||||
$user->notify(new NewUser($event->user));
|
})->get()->each(function ($user, $key) use ($event) {
|
||||||
}
|
$user->notify(new NewUser($event->user));
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user