-
I am not able to set up jobs in the landlord database. (Haven't setup tenant aware jobs yet). I am trying to send a welcome email when the tenant registers. But the queue is not able to find the landlord database to set up jobs. And this is the job that I made which is NotTenantAware: <?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use App\Mail\SchoolRegistered;
use Illuminate\Support\Facades\Mail;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Spatie\Multitenancy\Jobs\NotTenantAware;
use Spatie\Multitenancy\Models\Concerns\UsesLandlordConnection;
class SendWelcomeEmailJob implements ShouldQueue, NotTenantAware
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $details;
protected $url;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($details, $domain)
{
$this->details = $details;
$this->domain = $domain;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Mail::to($this->details['email'])->send(new SchoolRegistered($this->domain));
}
} I have setup the database connection inside the queue.php as: 'database' => [
'driver' => 'database',
'connection' => 'landlord',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
], I also have to set up tenant-aware jobs later, so not sure if the above configuration is what I should go with.
How to configure the queue.php and jobs files so they can handle both tenant-aware and not-tenant-aware jobs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I got the solution to the problem. I had set queues are tenant aware option to true in Multitenancy.config. After turning it off, the code works. |
Beta Was this translation helpful? Give feedback.
I got the solution to the problem. I had set queues are tenant aware option to true in Multitenancy.config. After turning it off, the code works.