4 years ago

L5 Multiple Databases based on subdomein

Posted 4 years ago by rene


I have the following:

What I want, is to access a separate database, based on the subdomain.

Using Sub-domain routing of course:

Route::group(['domain' => '{account}'], function()

    Route::get('user/{id}', function($account, $id)
        // use user-specific database


But how can I get a different database, based on the subdomain? I thought of a middle-ware-kinda-thing, and set database in a Session, but that's not preferable.

All other settings keep the same: host, username, password etc. Only database needs to change.

Please sign in or create an account to participate in this conversation.