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
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function reset2FASecret(Reset2FASecretRequest $request, User $user) {
|
public function reset2FASecret(Reset2FASecretRequest $request, User $user) {
|
||||||
|
// note: could invalidate other sessions for increased security
|
||||||
if ($user->has2FA()) {
|
if ($user->has2FA()) {
|
||||||
Log::warning('SECURITY: Disabling two factor authentication (admin initiated)', [
|
Log::warning('SECURITY: Disabling two factor authentication (admin initiated)', [
|
||||||
'initiator' => $request->user()->email,
|
'initiator' => $request->user()->email,
|
||||||
|
@ -94,11 +94,12 @@ class ApplicationService
|
|||||||
'applicant' => $applicant->name
|
'applicant' => $applicant->name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
User::whereHas('roles', function ($q) {
|
||||||
if ($user->hasRole('admin')) {
|
$q->where('name', 'admin');
|
||||||
|
})->get()->each(function ($user, $key) use ($application, $vacancy) {
|
||||||
$user->notify((new NewApplicant($application, $vacancy->first())));
|
$user->notify((new NewApplicant($application, $vacancy->first())));
|
||||||
}
|
});
|
||||||
}
|
|
||||||
$application->user->notify(new ApplicationConfirmed($application));
|
$application->user->notify(new ApplicationConfirmed($application));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user