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

ACDMan's avatar
Level 1

Laravel Auth - Custom Column Names

Hello! I'm a bit new to Laravel and I've been recently looking into Authentications. I was able to create a simple Login and Registration using the default User Model and login via the built in Auth:attempt.

Now, I've been trying to convert an existing website for testing purposes but the existing database was made via plain PHP and their database do not follow Laravel's naming conventions so I've been having a problem on making Auth:attempt work on the custom columns. I've been messing around with the my website's default User model a bit and it seems public function getAuthPassword() deals with handling the column name for the password but I dont know which function handles the username part of the authentication. I tried getAuthIdentifier and getAuthIdentifierName and neither seems to work or modify what column name the Auth:attempt is using.

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

Just attempt with an array of the custom username column, e.g.

Auth::attempt(['my_special_username_column' => 'ACDMan', 'password' => 'password123']);
1 like
ACDMan's avatar
Level 1

@tykus That works. Thanks! Does the password array key also affect the column being checked for the password or does it default to what is set via getAuthPassword()?

Edit: Oops, nevermind. Tested it on my side, it defaults to getAuthPassword. Thanks again for the solution!

tykus's avatar

@ACDMan no worries; please mark the thread solved if you're all set

Please or to participate in this conversation.