Skip to content

Commit 846d1a0

Browse files
[10.x]: improve job release method to accept date instance (#46854)
* [10.x]: improve job release method to accept date instance * Update InteractsWithQueue.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 7136338 commit 846d1a0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Illuminate/Queue/InteractsWithQueue.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
namespace Illuminate\Queue;
44

5+
use DateTimeInterface;
56
use Illuminate\Contracts\Queue\Job as JobContract;
7+
use Illuminate\Support\InteractsWithTime;
68
use InvalidArgumentException;
79
use Throwable;
810

911
trait InteractsWithQueue
1012
{
13+
use InteractsWithTime;
14+
1115
/**
1216
* The underlying queue job instance.
1317
*
@@ -61,11 +65,15 @@ public function fail($exception = null)
6165
/**
6266
* Release the job back into the queue after (n) seconds.
6367
*
64-
* @param int $delay
68+
* @param \DateTimeInterface|\DateInterval|int $delay
6569
* @return void
6670
*/
6771
public function release($delay = 0)
6872
{
73+
$delay = $delay instanceof DateTimeInterface
74+
? $this->secondsUntil($delay)
75+
: $delay;
76+
6977
if ($this->job) {
7078
return $this->job->release($delay);
7179
}

0 commit comments

Comments
 (0)