refactor: remove n+1 query from application admin notification
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
parent
d5521030a0
commit
cfc1d1038b
@ -534,7 +534,7 @@ class UserController extends Controller
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function reset2FASecret(Reset2FASecretRequest $request, User $user) {
|
||||
|
||||
// note: could invalidate other sessions for increased security
|
||||
if ($user->has2FA()) {
|
||||
Log::warning('SECURITY: Disabling two factor authentication (admin initiated)', [
|
||||
'initiator' => $request->user()->email,
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user