From 846d1a0cb8625cadc7913bcf25fec62614289dd9 Mon Sep 17 00:00:00 2001 From: Anjorin Damilare Date: Mon, 24 Apr 2023 20:32:06 +0100 Subject: [PATCH] [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 --- src/Illuminate/Queue/InteractsWithQueue.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/InteractsWithQueue.php b/src/Illuminate/Queue/InteractsWithQueue.php index 36a86aeacf33..9193b878f470 100644 --- a/src/Illuminate/Queue/InteractsWithQueue.php +++ b/src/Illuminate/Queue/InteractsWithQueue.php @@ -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. * @@ -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); }