title: Laravel 6 config()->get('database.connections.mysql') not matching DB:connection()
body: <h3>Prerequisites</h3>
  
  <p>In my local environment I am working with multiple tenants and Redis (Auth required).<br>
  To serve the project I am using Valet.  </p>
  
  <p>For this case I am addressing these two connections:</p>
  
  <pre><code>- basic_foo (is defined in my .env)
  - tenant_foo (is the one to change to during a request)
  </code></pre>
  
  <p>Until now I successfully changed the connections like so:</p>
  
  <pre><code>config()-&gt;set('database.connections.mysql', 
         array_merge(
          config()-&gt;get('database.connections.mysql') , 
          ['database' =&gt; 'tenant_foo']
      ); 
  </code></pre>
  
  <h3>Problem</h3>
  
  <p>However, now I am seeing an issue with the query builder, keeping or falling back to the basic connection. </p>
  
  <p>I get the expected connection results of <em>tenant_foo</em> (same for Redis) when I run</p>
  
  <pre><code>dd(config()-&gt;get('database.connections.mysql'));
  </code></pre>
  
  <p>I get the wrong but apparently active results of <em>basic_foo</em> when I run</p>
  
  <pre><code>dd(\DB::connection()); // returns Illuminate\Database\MySqlConnection
  </code></pre>
  
  <p>So all in all the app will return this Illuminate\Database\QueryException  </p>
  
  <pre><code>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'basic_foo.table_bar' doesn't exist...
  </code></pre>
  
  <p>where it should search for </p>
  
  <pre><code>'tenant_foo.table_bar'
  </code></pre>
  
  <h3>Things that did not solve the problem yet</h3>
  
  <ul>
  <li>restarting Redis</li>
  <li>reinstalling Redis</li>
  <li>php artisan config:cache</li>
  <li>php artisan cache:clear</li>
  <li>php artisan route:clear</li>
  <li>php artisan view:clear</li>
  <li>php artisan optimize</li>
  <li>composer dump-autoload</li>
  </ul>
  
  <p>Simply changing the database name to <em>tenant_foo</em> like below is not enough, as the config array remains the same  of <em>basic_foo</em>. </p>
  
  <pre><code>\DB::connection()-&gt;setDatabaseName('tenant_foo');
  </code></pre>
  
  <h3>Thoughts</h3>
  
  <ul>
  <li>I want to change the config-array the of <em>\DB::connection()</em>, but I don't know another way than the config->set().</li>
  <li>I installed Telescope could this affect the db connection? </li>
  <li>Any other ideas?</li>
  </ul>