leocavalcante
leocavalcante

I want to do something like Multisites plugin does for themes, but for the database too.

Depending of the domain used, I want to set a different database, same host, user and pass, just another database name.

How can I do that?

Already tried Config::set('database.mysql.database', 'blah') at plugins public function boot(), but doesn't work

leocavalcante
leocavalcante

Did it at config.php level.

'database' => (function(){
    $host = Request::getHost();

    if (preg_match('/blah/', $host)) {
        return env('BLAH_DB_DATABASE');
    }

    return env('DB_DATABASE', 'database');
})(),

But it is something we, in Brazil, like to call: Gambiarra.

Would be nice to have a proper way to do that.

1-2 of 2