Is there another way to "setConnection" on an Eloquent Model? : <p>I am currently handling a "multi db on the fly swap connections" sort of project.</p>

<p>So what I end up doing is the following:</p>

<pre><code>$connectionName = uniqid();
\Config::set('database.connections.' . $connectionName, [/** db options **/]);
\Artisan::call('migrate', ['--database' =&gt; $connectionName]);
</code></pre>

<p>or </p>

<pre><code>$connectionName = uniqid();           
\Config::set('database.connections.' . $connectionName,[/** db options **/]);

$user = new User();
$user-&gt;setConnection($connectionName);
$user-&gt;first_name = 'Daisy';
$user-&gt;last_name = 'Demo';
$user-&gt;is_not_being_ignored_by_santa_this_year = 0;
$user-&gt;email = //and so so on
$user-&gt;save();
</code></pre>

<p>For the Artisan call I sort of understand why Laravel needs to refer to a connection in a string, saved in a config array. </p>

<p>However on the Eloquent Model itself I find it somehow cumbersome to have to write my DB connection into a config array. So it can be picked up by  the "Singleton approach" \Config::get().. in the Model. </p>

<p>Is there something more elegant, where I can inject a configuration directly without having to write it into some super global ?</p>

<p>Or am I missing something ?</p>
