You can generate a job by following command.
php artisan better:job StoreBlog Blog
INFO
Generated job will be at app/Domains/Blog/Jobs/StoreBlogJob.php
use Laranex\BetterLaravel\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\BetterLaravel\Cores\QueueableJob
.
use Laranex\BetterLaravel\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
}
}