Skip to content

Commit

Permalink
Add failed() on InteractsWithQueue.
Browse files Browse the repository at this point in the history
Allow to failed a job when using InteractsWithQueue instead of just
deleting the job.

Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Mar 19, 2016
1 parent 8541fcb commit 638e32a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Illuminate/Queue/InteractsWithQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ trait InteractsWithQueue
*/
protected $job;

/**
* Get the number of times the job has been attempted.
*
* @return int
*/
public function attempts()
{
return $this->job ? $this->job->attempts() : 1;
}

/**
* Delete the job from the queue.
*
Expand All @@ -26,26 +36,28 @@ public function delete()
}

/**
* Release the job back into the queue.
* Fail the job from the queue.
*
* @param int $delay
* @return void
*/
public function release($delay = 0)
public function failed()
{
if ($this->job) {
return $this->job->release($delay);
return $this->job->failed();
}
}

/**
* Get the number of times the job has been attempted.
* Release the job back into the queue.
*
* @return int
* @param int $delay
* @return void
*/
public function attempts()
public function release($delay = 0)
{
return $this->job ? $this->job->attempts() : 1;
if ($this->job) {
return $this->job->release($delay);
}
}

/**
Expand Down

0 comments on commit 638e32a

Please sign in to comment.