LaravelPackages.net
Acme Inc.
Toggle sidebar
enimiste/laravel-uniqueable-jobs-l54

Laravel 5.4 uniqueable jobs support

130
4
v5.6.0
About enimiste/laravel-uniqueable-jobs-l54

enimiste/laravel-uniqueable-jobs-l54 is a Laravel package for laravel 5.4 uniqueable jobs support. It currently has 4 GitHub stars and 130 downloads on Packagist (latest version v5.6.0). Install it with composer require enimiste/laravel-uniqueable-jobs-l54. Discover more Laravel packages by enimiste or browse all Laravel packages to compare alternatives.

Last updated

Laravel Uniqueable Jobs

Install

Require this package with composer using the following command (Laravel 5.6) :

composer require "enimiste/laravel-uniqueable-jobs-l54:5.6.*"

For Laravel 5.4 :

composer require "enimiste/laravel-uniqueable-jobs-l54:5.4.*"

After updating composer, add the service provider to the providers array in config/app.php

Com\NickelIT\UniqueableJobs\UniqueableJobsServiceProvider::class,

Publish migration :

php artisan queue:table
php artisan vendor:publish  --tag=migrations

In your Jobs classes use Com\NickelIT\UniqueableJobs\Dispatchable and Com\NickelIT\UniqueableJobs\Uniqueable instead of the default ones.
NB : This trait should be used directly in the job class and not in the base class if exists.

To ensure that a given job will be stored in the database once per model and model id you use ->unique(Model::class, $model->id) on the job instance or after calling dispatch() method like :

$u = User::first();
DoSomethingJob::dispatch('Hello from unique job ' . $u->email)
                        ->unique(User::class, $u->id);
DoSomethingJob::dispatch('Hello from unique job ' . $u->email)
                        ->unique(User::class, $u->id);
//In this case the job will be stored once if it was already in the db

License

The Laravel Uniqueable Jobs is open-sourced software licensed under the MIT license

Star History Chart