What i am doing is, want to create table in another database which is not set in .env file. and i want to do this on controller functionality. And I am using a eloquent model throughtout my project. How to create table with this scenario?
Asked
Active
Viewed 1,108 times
0
-
1This will help: http://stackoverflow.com/questions/31847054/how-to-use-multiple-database-in-laravel – szebasztian Oct 18 '16 at 15:15
1 Answers
0
In addition to the linked question that @szebasztian provided in the comment, take a look at the documentation. You can specify what connection Schema
will use to create the table when running a migration in this way:
Schema::connection('foo')->create('users', function ($table) {
$table->increments('id');
});
foo
is the new connection you define in config/database.php
. I would personally still add the connection details (host, username, password, etc) to .env
for that information.

Jeff Lambert
- 24,395
- 4
- 69
- 96