/** * Execute the console command. * * @return void */ public function fire() { $queue = $this->argument('queue') ? $this->argument('queue') : \Config::get('queue.connections.beanstalkd.queue'); $this->info(sprintf('Clearing queue: %s', $queue)); $pheanstalk = \Queue::getPheanstalk(); $pheanstalk->useTube($queue); $pheanstalk->watch($queue); while ($job = $pheanstalk->reserve(0)) { $pheanstalk->delete($job); } $this->info('Queue successfully cleared.'); }
/** * Execute the console command. * * @return void */ public function fire() { $queue = $this->argument('queue') ? $this->argument('queue') : \Config::get('queue.connections.beanstalkd.queue'); $this->info(sprintf('Clearing queue: %s', $queue)); $pheanstalk = \Queue::getPheanstalk(); $pheanstalk->useTube($queue); $pheanstalk->watch($queue); while ($job = $pheanstalk->reserve(0)) { $pheanstalk->delete($job); } // Set the flag of the jobs $jobs = \Job::all(); foreach ($jobs as $job) { $job->added_to_queue = false; $job->save(); } $this->info('The Beankstalk queue has been cleared.'); }