title: Laravel 5: Using Cache:: or DB:: within the Console Kernel's schedule() function
body: <p>I'm trying to run an Artisan console command in Laravel 5 at varying, user-configured time intervals. I have built the console command and have a database (with Eloquent model) holding a "run frequency" configuration value.</p>
  
  <p>Within the <code>schedule()</code> function of <code>App\Console\Kernel.php</code> I'd like to pull this value out of the database and run the command as and when needed based on this value.</p>
  
  <p>I receive a <code>Fatal error: Class 'DB' not found</code> when using <code>DB::table()...</code> with or without <code>use DB;</code>, and the same happens if I try to use <code>Cache::...</code> functions too.</p>
  
  <p>I'm assuming the IoC container isn't accessible from within the <code>schedule()</code> function of <code>App\Console\Kernel.php</code> file. Has anyone had similar and found an elegant workaround?</p>
  
  <p>My simplified code is:</p>
  
  <pre><code>&lt;?php namespace App\Console;
  
  use Cache;
  use Illuminate\Console\Scheduling\Schedule;
  use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  
  class Kernel extends ConsoleKernel {
  
      /**
       * Define the application's command schedule.
       *
       * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
       * @return void
       */
      protected function schedule(Schedule $schedule)
      {
          $settings = Cache::get('settings');
      }
  </code></pre>
  
  <p>and the error:</p>
  
  <pre><code>php artisan schedule:run
  PHP Fatal error:  Class 'Cache' not found in /home/vagrant/projects/project/dir/api/app/Console/Kernel.php on line 26
  </code></pre>
  
  <p>any help would be greatfully appreciated</p>