InteractsWithQueue.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Illuminate\Queue;
use Illuminate\Contracts\Queue\Job as JobContract;
trait InteractsWithQueue
{
/**
* The underlying queue job instance.
*
* @var \Illuminate\Contracts\Queue\Job
*/
public $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.
*
* @return void
*/
public function delete()
{
if ($this->job) {
return $this->job->delete();
}
}
/**
* Fail the job from the queue.
*
* @param \Throwable|null $exception
* @return void
*/
public function fail($exception = null)
{
if ($this->job) {
$this->job->fail($exception);
}
}
/**
* Release the job back into the queue.
*
* @param int $delay
* @return void
*/
public function release($delay = 0)
{
if ($this->job) {
return $this->job->release($delay);
}
}
/**
* Set the base queue job instance.
*
* @param \Illuminate\Contracts\Queue\Job $job
* @return $this
*/
public function setJob(JobContract $job)
{
$this->job = $job;
return $this;
}
}