File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Doppar \Queue ;
44
5+ use Doppar \Queue \Facades \Queue ;
56use Doppar \Queue \Contracts \JobInterface ;
67
78abstract class Job implements JobInterface
@@ -145,4 +146,53 @@ public function delayFor(int $delay): self
145146
146147 return $ this ;
147148 }
149+
150+ /**
151+ * Dispatch the job to the queue.
152+ *
153+ * @return string Job ID
154+ */
155+ public function dispatch (): string
156+ {
157+ return Queue::push ($ this );
158+ }
159+
160+ /**
161+ * Dispatch the job to the queue after a delay.
162+ *
163+ * @param int $delay Delay in seconds
164+ * @return string Job ID
165+ */
166+ public function dispatchAfter (int $ delay ): string
167+ {
168+ $ this ->delayFor ($ delay );
169+
170+ return $ this ->dispatch ();
171+ }
172+
173+ /**
174+ * Dispatch the job to a specific queue.
175+ *
176+ * @param string $queue
177+ * @return string Job ID
178+ */
179+ public function dispatchOn (string $ queue ): string
180+ {
181+ $ this ->onQueue ($ queue );
182+
183+ return $ this ->dispatch ();
184+ }
185+
186+ /**
187+ * Dispatch the job.
188+ *
189+ * @param mixed ...$args
190+ * @return string Job ID
191+ */
192+ public static function dispatchNow (...$ args ): string
193+ {
194+ $ job = new static (...$ args );
195+
196+ return $ job ->dispatch ();
197+ }
148198}
You can’t perform that action at this time.
0 commit comments