You can generate an operation by following command.
php artisan next:operation NotifySubscribersOperation Blog
INFO
Generated operation will be at app/Modules/BlogModule/Operations/NotifySubscribersOperation.php
WARNING
Operation must extend the Next Laravel operation Laranex\NextLaravel\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\Modules\BlogModule\Jobs\NotifyViaEmailJob;
use App\Modules\BlogModule\Jobs\NotifyViaPushNotificationJob;
use Laranex\NextLaravel\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\Modules\BlogModule\Jobs\NotifyViaEmailJob;
use App\Modules\BlogModule\Jobs\NotifyViaPushNotificationJob;
use Laranex\NextLaravel\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));
}
}