title: InvalidArgumentException: Database [advertiser] not configured.
body: <p>I have this weird error. In our app when an user creates or updates a group, we are adding that group to our Solr search index or update existing data through events. It used to work fine but now it has started to throw this error.</p>
  <p><strong>database.php</strong></p>
  <pre><code>'connections' =&gt; [
  
          'mongodb' =&gt; [
              'driver'   =&gt; 'mongodb',
              'host'     =&gt; env('MONGO_DB_HOST', 'localhost'),
              'port'     =&gt; env('MONGO_DB_PORT', 27017),
              'database' =&gt; env('MONGO_DB_DATABASE'),
              'username' =&gt; env('MONGO_DB_USERNAME'),
              'password' =&gt; env('MONGO_DB_PASSWORD'),
              'options' =&gt; [
                  'db' =&gt; 'admin', // sets the authentication database required by mongo 3
              ]
          ],
  
          'advertiser' =&gt; [
              'driver'   =&gt; 'mysql',
              'host'     =&gt; env('ADVERTISER_DB_HOST', 'localhost'),
              'port'     =&gt; env('ADVERTISER_DB_PORT', 3306),
              'database' =&gt; env('ADVERTISER_DB_DATABASE'),
              'username' =&gt; env('ADVERTISER_DB_USERNAME'),
              'password' =&gt; env('ADVERTISER_DB_PASSWORD'),
              'charset' =&gt; 'utf8',
              'collation' =&gt; 'utf8_unicode_ci',
              'prefix' =&gt; '',
              'strict' =&gt; true,
              'engine' =&gt; null,
          ],
  
          'sqlite' =&gt; [
              'driver' =&gt; 'sqlite',
              'database' =&gt; env('DB_DATABASE', database_path('database.sqlite')),
              'prefix' =&gt; '',
          ],
  
          'mysql' =&gt; [
              'driver' =&gt; 'mysql',
              'host' =&gt; env('DB_HOST', 'localhost'),
              'port' =&gt; env('DB_PORT', '3306'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
              'password' =&gt; env('DB_PASSWORD', ''),
              'charset' =&gt; 'utf8',
              'collation' =&gt; 'utf8_unicode_ci',
              'prefix' =&gt; '',
              'strict' =&gt; true,
              'engine' =&gt; null,
          ],
  
          'pgsql' =&gt; [
              'driver' =&gt; 'pgsql',
              'host' =&gt; env('DB_HOST', 'localhost'),
              'port' =&gt; env('DB_PORT', '5432'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
              'password' =&gt; env('DB_PASSWORD', ''),
              'charset' =&gt; 'utf8',
              'prefix' =&gt; '',
              'schema' =&gt; 'public',
              'sslmode' =&gt; 'prefer',
          ],
  
      ],
  </code></pre>
  <p>The listener method in <code>GroupEventSubscriber.php</code></p>
  <pre><code>public function onNewGroupCreate(\App\Events\NewGroupCreate $event)
      {
          $group = $event-&gt;group;
          // this method adds the group to our solr index
          // i've commented out the method call after it started to throw error, but it still being called. 
          // the onGroupUpdate() method is similar to this
          //$this-&gt;addGroupToIndex($group);
      }
  </code></pre>
  <p>Now every time I create or update a group this is the stacktrace i get. Note: I have commented out the <code>addGroupToIndex()</code> method call in both <code>onGroupUpdate()</code> and `onNewGroupCreate()</p>
  <p>InvalidArgumentException: Database [advertiser] not configured.
  in /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:239</p>
  <blockquote>
  <p>Stack trace:</p>
  <h1>0 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(158):</h1>
  <p>Illuminate\Database\DatabaseManager-&gt;getConfig('advertiser')</p>
  <h1>1 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(68):</h1>
  <p>Illuminate\Database\DatabaseManager-&gt;makeConnection('advertiser')</p>
  <h1>2 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3351):</h1>
  <p>Illuminate\Database\DatabaseManager-&gt;connection('advertiser')</p>
  <h1>3 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3317):</h1>
  <p>Illuminate\Database\Eloquent\Model::resolveConnection('advertiser')</p>
  <h1>4 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1861):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;getConnection()</p>
  <h1>5 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1834):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;newBaseQueryBuilder()</p>
  <h1>6 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1804):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;newQueryWithoutScopes()</p>
  <h1>7 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(726):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;newQuery()</p>
  <h1>8 /var/www/tagfi/api/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php(26):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;hasOne('App\Advertiser', 'id',
  'place_id')</p>
  <h1>9 /var/www/tagfi/api/app/Group.php(67): App\Group-&gt;hasOne('App\Advertiser', 'id', 'place_id')</h1>
  <h1>10 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2706):</h1>
  <p>App\Group-&gt;advertiser()</p>
  <h1>11 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2679):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;getRelationshipFromMethod('advertiser')</p>
  <h1>12 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2623):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;getRelationValue('advertiser')</p>
  <h1>13 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3466):</h1>
  <p>Illuminate\Database\Eloquent\Model-&gt;getAttribute('advertiser')</p>
  <h1>14 /var/www/tagfi/api/app/Listeners/GroupEventSubscriber.php(50): Illuminate\Database\Eloquent\Model-&gt;__get('advertiser')</h1>
  <h1>15 /var/www/tagfi/api/app/Listeners/GroupEventSubscriber.php(90): App\Listeners\GroupEventSubscriber-&gt;addGroupToIndex(Object(App\Group))</h1>
  <h1>16 [internal function]: App\Listeners\GroupEventSubscriber-&gt;onGroupUpdate(Object(App\Events\GroupUpdate))</h1>
  <h1>17 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Events/CallQueuedHandler.php(42):</h1>
  <p>call_user_func_array(Array, Array)</p>
  <h1>18 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(73):</h1>
  <p>Illuminate\Events\CallQueuedHandler-&gt;call(Object(Illuminate\Queue\Jobs\RedisJob),
  Array)</p>
  <h1>19 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(203):</h1>
  <p>Illuminate\Queue\Jobs\Job-&gt;fire()</p>
  <h1>20 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(152):</h1>
  <p>Illuminate\Queue\Worker-&gt;process('redis',
  Object(Illuminate\Queue\Jobs\RedisJob),
  Object(Illuminate\Queue\WorkerOptions))</p>
  <h1>21 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(75):</h1>
  <p>Illuminate\Queue\Worker-&gt;runNextJob('redis', 'default',
  Object(Illuminate\Queue\WorkerOptions))</p>
  <h1>22 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(100):</h1>
  <p>Illuminate\Queue\Worker-&gt;daemon('redis', 'default',
  Object(Illuminate\Queue\WorkerOptions))</p>
  <h1>23 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(83):</h1>
  <p>Illuminate\Queue\Console\WorkCommand-&gt;runWorker('redis', 'default')</p>
  <h1>24 [internal function]: Illuminate\Queue\Console\WorkCommand-&gt;fire()</h1>
  <h1>25 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(508):</h1>
  <p>call_user_func_array(Array, Array)</p>
  <h1>26 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(169):</h1>
  <p>Illuminate\Container\Container-&gt;call(Array)</p>
  <h1>27 /var/www/tagfi/api/vendor/symfony/console/Command/Command.php(261):</h1>
  <p>Illuminate\Console\Command-&gt;execute(Object(Symfony\Component\Console\Input\ArgvInput),
  Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>28 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(155):</h1>
  <p>Symfony\Component\Console\Command\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput),
  Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>29 /var/www/tagfi/api/vendor/symfony/console/Application.php(817): Illuminate\Console\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput),</h1>
  <p>Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>30 /var/www/tagfi/api/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application-&gt;doRunCommand(Object(Illuminate\Queue\Console\WorkCommand),</h1>
  <p>Object(Symfony\Component\Console\Input\ArgvInput),
  Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>31 /var/www/tagfi/api/vendor/symfony/console/Application.php(116): Symfony\Component\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput),</h1>
  <p>Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>32 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121):</h1>
  <p>Symfony\Component\Console\Application-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput),
  Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>33 /var/www/tagfi/api/artisan(35): Illuminate\Foundation\Console\Kernel-&gt;handle(Object(Symfony\Component\Console\Input\ArgvInput),</h1>
  <p>Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
  <h1>34 {main}</h1>
  </blockquote>
  <p>i know this is too long, but I can't seem to find whats causing the issue.</p>