I have a project that must to be accessed through these 2 URLs us_myproject.com
and es_myproject.com
.
They share the same folders and code. In fact there are only one laravel project: htdocs/myproject
.
depending on URL the information must to come from us_db
or es_db
, based on the URL used.
So my question is how to set .env
db credentials to point to these 2 different databases. I have 2 different databases, 2 different user and 2 different password. How can I accomplish this task?
I have this follow code that works:
URL: us_myproject.com/dbtest
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=us_db
DB_USERNAME=root
DB_PASSWORD=''
Route::get('dbtest',function(){//Works good
$tblusertypes=DB::table("tblusertypes")->get();
return $tblusertypes;
});
If I do URL: es_myproject.com/dbtest
should query against es_db
but I dont know how to set this. Any Idea?