Skip to content

Commit

Permalink
[10.x]: improve job release method to accept date instance (laravel#4…
Browse files Browse the repository at this point in the history
…6854)

* [10.x]: improve job release method to accept date instance

* Update InteractsWithQueue.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
dammy001 and taylorotwell authored Apr 24, 2023
1 parent 7136338 commit 846d1a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Illuminate/Queue/InteractsWithQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

namespace Illuminate\Queue;

use DateTimeInterface;
use Illuminate\Contracts\Queue\Job as JobContract;
use Illuminate\Support\InteractsWithTime;
use InvalidArgumentException;
use Throwable;

trait InteractsWithQueue
{
use InteractsWithTime;

/**
* The underlying queue job instance.
*
Expand Down Expand Up @@ -61,11 +65,15 @@ public function fail($exception = null)
/**
* Release the job back into the queue after (n) seconds.
*
* @param int $delay
* @param \DateTimeInterface|\DateInterval|int $delay
* @return void
*/
public function release($delay = 0)
{
$delay = $delay instanceof DateTimeInterface
? $this->secondsUntil($delay)
: $delay;

if ($this->job) {
return $this->job->release($delay);
}
Expand Down

0 comments on commit 846d1a0

Please sign in to comment.