Hello, good afternoon, I have a question about the correct way to work with different databases in the same project. for example I have: . BASE_01 . BASE_02, and in my config.database I have:.
'BASE_01' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => 'BASE_01', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''),
],
'BASE_02'=>[
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => 'BASE_02',
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
],
and the db variable is saved in session, according to the session variable I make the query to the specific db. My question is, is there another way to do it or is what I'm doing right?
Are you trying to build a multi-tenant application? If so check this package out https://tenancyforlaravel.com/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community