Could you add something like this on your User model?
public function login()
{
throw_unless($this->is_enabled, new AuthenticationException('This dude is not enabled!'));
return auth()->login($this);
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a situation where my application has a users and accounts table, with each account having many users.
On login I need to perform the usual user authentication, but I also need to check if the users account is enabled, and I’m unsure how to do that without overwriting large chunks of the AuthenticateUsers trait in the LoginController.
I know that I can write a custom credentials method in the LoginController to include additional fields from the users table, but how do I get that to reference a field in another table? Eg: $user->account->enabled.
Also, I need to return a different error message if the account is not enabled.
Right now I’m doing all of this with a custom login method in the LoginController, but that seems nasty.
Any pointers on how to improve this would be appreciated!
(edit: for clarification, I'm trying to change as little of the Laravel boilerplate authentication code as possible)
Cheers, Sab.
Please or to participate in this conversation.