PHP code example of campelo / laravel-queue-control
1. Go to this page and download the library: Download campelo/laravel-queue-control library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
campelo / laravel-queue-control example snippets
use Campelo\QueueControl\Traits\Cancellable;
class SendEmailJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Cancellable;
public function handle()
{
// Your job logic
}
}
// Group related jobs with a campaign ID
SendEmailJob::dispatch($user)->withCampaign('newsletter-42');
SendPushJob::dispatch($user)->withCampaign('newsletter-42');
// All these jobs belong to the same campaign
SendEmailJob::dispatch($user)->withCampaign('black-friday-2024');
SendSmsJob::dispatch($user)->withCampaign('black-friday-2024');
SendPushJob::dispatch($user)->withCampaign('black-friday-2024');
// Cancel all at once
QueueControl::cancelCampaign('black-friday-2024');
'permissions' => [
'pause' => ['admin'], // Only admins can pause
'resume' => ['admin', 'ops'], // Admin and ops can resume
'cancel' => ['admin', 'ops'], // Admin and ops can cancel
'clear' => ['admin'], // Only admins can clear
],