Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

RicardoAbel's avatar

Laravel 11, Spatie multi-tenancy queues are not triggered

Im using Laravel 11, with Spatie/Multi-tenancy package. to create a multi tenancy SaaS application.

Here is my database.php

  'tenant' => [
       'driver' => 'mysql',
      'url' => env('DB_URL'),
      'host' => env('DB_HOST', '127.0.0.1'),
      'port' => env('DB_PORT', '3306'),
      'database' => null,
      'username' => env('DB_USERNAME', 'root'),
      'password' => env('DB_PASSWORD', ''),
      'unix_socket' => env('DB_SOCKET', ''),
      'charset' => env('DB_CHARSET', 'utf8mb4'),
      'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
      'prefix' => '',
      'prefix_indexes' => true,
      'strict' => true,
      'engine' => null,
      'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
      ]) : [],
  ],

'landlord' => [
    'driver' => 'mysql',
    'url' => env('DB_URL'),
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => 'landlord_db',
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => env('DB_CHARSET', 'utf8mb4'),
    'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
    'prefix' => '',
    'prefix_indexes' => true,
    'strict' => true,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],
],

env file

 DB_CONNECTION=tenant
 DB_HOST=mysql_db
 DB_PORT=3306
 DB_DATABASE=landlord_db
 DB_USERNAME=root
 DB_PASSWORD=root

Event:

 class HostRegistered
 {
use Dispatchable, InteractsWithSockets, SerializesModels;

public User $user;

/**
 * Create a new event instance.
 */
public function __construct(User $user)
{
    $this->user = $user;
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return array<int, \Illuminate\Broadcasting\Channel>
 */
 public function broadcastOn(): array
 { 
    return [
        new PrivateChannel('channel-name'),
    ];
}
}

Listener:

 class SendHostRegistrationEmail
 {
 /**
 * Create the event listener.
 */
 public function __construct()
 {

 }

 /**
  * Handle the event.
  */
  public function handle(HostRegistered $event): void
  {
    dispatch(new HostRegistrationEmailVerificationJob($event->user));
  }
  }


  class HostRegistrationEmailVerificationJob implements ShouldQueue, TenantAware
   {
   public $user;

  public function __construct($user)
   {
     $this->user = $user;
   }

   public function handle()
   {
    // Step 1: Log the job for debugging
    Log::info('HostRegistrationEmailVerificationJob is being handled.');

    // Step 2: Send the email verification
    try {
        Mail::to($this->user->email)->send(new RegistrationEmailVerification($this->user));
        Log::info('Verification email sent to: ' . $this->user->email);
     } catch (\Exception $e) {
        Log::error('Failed to send verification email: ' . $e->getMessage());
      }
   }
 }

my issue is queues are not triggered:

php artisan queue:work
0 likes
4 replies
jlrdw's avatar

Have you viewed their video on multi-tenancy.

And I suggest showing some of the other code you have that's not working, so someone can offer advice.

RicardoAbel's avatar

@jlrdw I did, my question is should i have DB_CONNECTION=tenant OR DB_CONNECTION=landlord

Please or to participate in this conversation.