refactor: remove n+1 query from application admin notification
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
@@ -94,11 +94,12 @@ class ApplicationService
|
||||
'applicant' => $applicant->name
|
||||
]);
|
||||
|
||||
foreach (User::all() as $user) {
|
||||
if ($user->hasRole('admin')) {
|
||||
$user->notify((new NewApplicant($application, $vacancy->first())));
|
||||
}
|
||||
}
|
||||
User::whereHas('roles', function ($q) {
|
||||
$q->where('name', 'admin');
|
||||
})->get()->each(function ($user, $key) use ($application, $vacancy) {
|
||||
$user->notify((new NewApplicant($application, $vacancy->first())));
|
||||
});
|
||||
|
||||
$application->user->notify(new ApplicationConfirmed($application));
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user