Laravel package to get the job id after dispatch
This package is very useful when you need the job id after dispatch and use it for other logic
- Install with composer
composer require arispati/laravel-dispatch-id
- Using class
use Arispati\LaravelDispatchId\Event;
use App\Jobs\TestJob;
// Basic dispatch
$jobId = Event::dispatch(new TestJob());
// Advanced dispatch
$job = (new TestJob())->delay(now()->addMinutes(10))
->onConnection('connection')
->onQueue('queue');
$jobId = Event::dispatch($job);
- Using helper function
use App\Jobs\TestJob;
// Basic dispatch
$jobId = dispatch_id(new TestJob());
// Advanced dispatch
$job = (new TestJob())->delay(now()->addMinutes(10))
->onConnection('connection')
->onQueue('queue');
$jobId = dispatch_id($job);