Have you configured your config/database.php file?
Try to configure it like this
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'database_1'), //forge
'username' => env('DB_USERNAME', 'root'), // forge
'password' => env('DB_PASSWORD', ''),
.......
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST_SQLSRV', '127.0.0.1'), // Notice that we change the default so that it'll refer to another variable which will be DB_HOST_SQLSRV in the .env file
'port' => env('DB_PORT_SQLSRV', '1433'),
'database' => env('DB_DATABASE2_SQLSRV', 'database_2'),
'username' => env('DB_USERNAME', 'root'), // Remains as is if you won't change the username and password, change it if you need to
'password' => env('DB_PASSWORD', ''),
.......
],
In your .env file it should look like this
// Mysql
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=hogedb
DB_USERNAME=hoge
DB_PASSWORD=password
// SQL Server
DB_CONNECTION=sqlsrv // We call in the 'sqlsrv' that we configured in database.php
DB_HOST_SQLSRV=localhost
DB_PORT_SQLSRV=1433 // DON'T FORGET THIS, IT'S VERY IMPORTANT!
DB_DATABASE2_SQLSRV=databasename // We change 'DB_Database' to 'DB_Database2'
DB_USERNAME=root // We may not add this to the second one unless you configured for another username & password in database.php
DB_PASSWORD=
So basically what you've configured in the database.php will fetch the data from your .env, if you notice it has the word env env('DB_PORT_SQLSRV', '1433')
Don't forget to run php artisan config:cache after changing something in the config folder