arispati/laravel-dispatch-id

Laravel package to get the job id after dispatch

v0.1.0 2021-10-15 11:50 UTC

This package is auto-updated.

Last update: 2024-10-29 06:36:33 UTC


README

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