Support the ongoing development of Laravel.io →
Authentication Database
Last updated 2 years ago.
0

You can create a second database connection (eg. 'user') in your config, and use Config::set('database.connections.user.username', $username) and similar for the password. You can then set models to use that database.

Last updated 2 years ago.
0

thank you :)

I have done the same:

  1. in the config->database.php->connections i have added a new db info and I called it with the same username
  2. in the models : $DB = DB::connection(Auth::user()->username); $company = $DB->select('SELECT * FROM company WHERE 1'); DB::disconnect(Auth::user()->username);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.