コード例 #1
0
 /**
  * Rollback changes performed by this migration.
  *
  * @return mixed
  */
 public function down()
 {
     $this->builder->table(Job::resolveTable()->getName(), function (Blueprint $table) {
         if (!$this->isSqlite()) {
             $table->dropColumn(['queue_connection', 'queue_name']);
         }
     });
 }
コード例 #2
0
 /**
  * Find jobs by a tag.
  *
  * @param string $tag
  * @param bool $activeOnly
  * @param int $take
  *
  * @return mixed
  */
 public function findByTag($tag, $activeOnly = true, $take = 20)
 {
     $jobsTable = Job::resolveTable();
     $jobTagsTable = JobTag::resolveTable();
     $query = Job::query()->leftJoin($jobTagsTable->getName(), $jobsTable->field('id'), '=', $jobTagsTable->field('job_id'))->where($jobTagsTable->field('name'), $tag)->take($take);
     if ($activeOnly) {
         $query->whereIn($jobsTable->field('state'), [JobState::SCHEDULED, JobState::RUNNING, JobState::QUEUED]);
     }
     return $query->get([$jobsTable->getName() . '.*']);
 }