Laravel Multiple DB Connections in Laravel From Laravel Documentation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Each individual connection can be accessed via the connection method on the DB facade, even when there are multiple connections defined. The name passed to the connection method should correspond to one of the connections listed in the config/database.php configuration file:

$users = DB::connection('foo')->select(...);

The raw can also be accessed, underlying PDO instance using the getPdo method on a connection instance:

$pdo = DB::connection()->getPdo();

https://laravel.com/docs/5.4/database#using-multiple-database-connections



Got any Laravel Question?