Looking to hire Laravel developers? Try LaraJobs

laravel-dispatch-id maintained by cryptoprof

Description
Laravel package to get the job id after dispatch
Author
Last update
2024/01/11 09:04 (dev-main)
License
Links
Downloads
47

Comments
comments powered by Disqus

Laravel Dispatch Id

Laravel package to get the job id after dispatch

Description

This package is very useful when you need the job id after dispatch and use it for other logic

How to Install

  • Install with composer
composer require arispati/laravel-dispatch-id

How to Use

  • 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);