@@ -28,10 +28,10 @@ public function __construct(array $config)
2828     */ 
2929    public  function  push ($ job , $ data  = '' , $ queue  = null )
3030    {
31-         $ id  = $ this  ->storeJob ($ job , $ data );
31+         $ id  = $ this  ->storeJob ($ job , $ data,  0 );
3232        $ this  ->startProcess ($ id , 0 );
3333
34-         return  0 ;
34+         return  $ id  ;
3535    }
3636
3737    /** 
@@ -62,31 +62,33 @@ public function storeJob($job, $data, $delay = 0)
6262     * Make a Process for the Artisan command for the job id. 
6363     * 
6464     * @param int $jobId 
65+      * @param int $delay 
6566     * 
6667     * @return void 
6768     */ 
68-     public  function  startProcess ($ jobId )
69+     public  function  startProcess ($ jobId,  $ delay  =  0 )
6970    {
7071        chdir ($ this  ->container ['path.base ' ]);
71-         exec ($ this  ->getCommand ($ jobId ));
72+         exec ($ this  ->getCommand ($ jobId,  $ delay  ));
7273    }
7374
7475    /** 
7576     * Get the Artisan command as a string for the job id. 
7677     * 
7778     * @param int $jobId 
79+      * @param int $delay 
7880     * 
7981     * @return string 
8082     */ 
81-     protected  function  getCommand ($ jobId )
83+     protected  function  getCommand ($ jobId,  $ delay  =  0 )
8284    {
83-         $ cmd  = '%s artisan queue:async %d --env=%s ' ;
85+         $ cmd  = '%s artisan queue:async %d --env=%s --delay=%d  ' ;
8486        $ cmd  = $ this  ->getBackgroundCommand ($ cmd );
8587
8688        $ binary  = $ this  ->getPhpBinary ();
8789        $ environment  = $ this  ->container ->environment ();
8890
89-         return  sprintf ($ cmd , $ binary , $ jobId , $ environment );
91+         return  sprintf ($ cmd , $ binary , $ jobId , $ environment,  $ delay  );
9092    }
9193
9294    /** 
@@ -127,9 +129,9 @@ public function later($delay, $job, $data = '', $queue = null)
127129    {
128130        $ delay  = $ this  ->getSeconds ($ delay );
129131        $ id  = $ this  ->storeJob ($ job , $ data , $ delay );
130-         $ this  ->startProcess ($ id );
132+         $ this  ->startProcess ($ id,  $ delay  );
131133
132-         return  0 ;
134+         return  $ id  ;
133135    }
134136
135137}
0 commit comments