Queues & Jobs
Because Qore uses multi-tenancy, your application will not be aware of which tenant, modules and plugins are active when you run a job asynchronously.
Initializing a tenant inside a job
You can add the following method (See also Job middleware
in Laravel docs) to your job:
private int $userId;
private int $tenantId;
public function __construct()
{
$this->userId = (int)auth()->id();
$this->tenantId = tenant()->id;
}
public function middleware(): array
{
return [new InitializeTenantJobMiddleware($this->userId, $this->tenantId)];
}
This middleware will make sure (before handle
is called) that the user will be logged in, the tenant will be initialized, and all the extensions will be booted.