Guiding me on this answer , I try to make multiple connections in the following way:
'connections' => [
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'sistematpm'),
'username' => env('DB_USERNAME', 'postgres'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'datos' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'sistematpm'),
'username' => env('DB_USERNAME', 'postgres'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'datos',
'sslmode' => 'prefer',
],
],
The connection I try it in the following way and it serves me perfectly.
$users = DB::connection('datos')->select(...);
All right up there, but my system has many drivers already created, it will be a bit tedious to indicate to each one what connection it makes reference to. Could you only edit the models to indicate where the table is?