Suppose there are two companies A and B. Each company has one user and when they login to their account i want to switch connection to their actual database. i.e If user "John" belongs to company A and "Rambo" belongs to company B. If John is logged in i want to switch the database to company A's database. Both company's database structure is same. So I'm trying to create separate database for each company. How to achieve this.
I have added another mysql connection in database.php and also entered its credentials in .env file. What is the next step? Can someone help me!
The user table looks something like this.
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('company')->default('A');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});