So we have a project which has two different database connections. After having read on the web for a bit I didn’t run into the ideal solution to inserting into a table which was not in the default database. It turned out to be pretty simple though:

These days it’s very uncommon for websites to user usernames and most sites just use the user’s email address.

Laravel has many, many very handy packages we can use to quickly get up and running and save us countless hours when developing a website but sometimes they do not do exactly what we want. In this case I relied on a package called Confide by Zizaco, commonly referred to as Zizaco/Confide. It started off pretty great with me having user creation, login, password reminders etc all working within 30 minutes. However, Zizaco/Confide heavily relies on the existance of a username for creating users and logging in. To get around this you will have to extend Zizaco\Confide\UserValidator and override $rules and also extend Zizaco\Confide\EloquentRepository and override the function getUserByEmailOrUsername.

To do this you can create a file in app/controllers with two classes in it and modify app/start/local.php to re-bind the Confide classes to your new ones so the original classes get overridden.

app/controllers/ConfideUsernameFix.php

app/start/local.php

UPDATE: Had to override the function validateIsUnique as well which required me to “use Zizaco\Confide\ConfideUserInterface;” to get it to work. Code fragment updated to reflect the new situation.