You can generate an operation by following command.
php artisan better:operation NotifySubscribersOperation Blog
INFO
Generated operation will be at app/Modules/BlogModule/Operations/NotifySubscribersOperation.php
WARNING
Operation must extend the Better Laravel operation Laranex\BetterLaravel\Cores\Operation
to work with the run
or runInQueue
method.
Calling jobs from a feature or an operation is straightforward using run
method.
use App\Domains\Blog\Jobs\NotifyViaEmailJob;
use App\Domains\Blog\Jobs\NotifyViaPushNotificationJob;
use Laranex\BetterLaravel\Cores\Operation;
class NotifySubscribersOperation extends Operation
{
private array $payload;
public function __construct(array $payload)
{
$this->payload = $payload;
}
public function handle(): void
{
$this->run(new NotifyViaEmailJob($this->payload));
$this->run(new NotifyViaPushNotificationJob($this->payload));
}
}
Calling queue jobs from a feature or an operation is straightforward using runInQueue
method.
use App\Domains\Blog\Jobs\NotifyViaEmailJob;
use App\Domains\Blog\Jobs\NotifyViaPushNotificationJob;
use Laranex\BetterLaravel\Cores\Operation;
class NotifySubscribersOperation extends Operation
{
private array $payload;
public function __construct(array $payload)
{
$this->payload = $payload;
}
public function handle(): void
{
$this->runInQueue(new NotifyViaEmailJob($this->payload));
$this->runInQueue(new NotifyViaPushNotificationJob($this->payload));
}
}