You can generate a job by following command.
php artisan next:job StoreBlog Blog
INFO
Generated job will be at app/Modules/BlogModule/Jobs/StoreBlogJob.php
use Laranex\NextLaravel\Cores\Job;
class StoreBlogJob extends Job
{
private array $payload;
public function __construct(array $payload)
{
$this->payload = $payload;
}
public function handle(): void
{
// here is your logic to handle data
}
}
You may turn any job into a queueable job that will be dispatched using Laravel Queues rather than running synchronously, by simply extending Laranex\NextLaravel\Cores\QueueableJob
.
use Laranex\NextLaravel\Cores\QueueableJob;
class NotifyViaEmailJob extends QueueableJob
{
private array $payload;
public function __construct(array $payload)
{
$this->payload = $payload;
}
public function handle(): void
{
// notify to each subscriber will be processed in the queue
}
}