Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

minaFaragAmin's avatar

how to change or override the login query

i want to customize the login query used to authenticate the users. thanks

0 likes
2 replies
Sti3bas's avatar
Sti3bas
Best Answer
Level 53

@minafaragamin if you only need to specify additional where or whereIn condition, you can override credential method in LoginController:

protected function credentials(Request $request)
{
   return array_merge([
      'is_admin' => true
   ], $request->only($this->username(), 'password'));
}

https://github.com/laravel/framework/blob/6.x/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L92

Otherwise, you would probably need to extend EloquentUserProvider and add the logic you want.

https://github.com/illuminate/auth/blob/master/EloquentUserProvider.php

3 likes

Please or to participate in this conversation.