I found a good solution while digging through the code of a popular multi-tenant suite for Laravel that did the trick. (Credit: https://github.com/tenancy/multi-tenant) and specificallly this trait (https://github.com/tenancy/multi-tenant/blob/1380789375bb3eb75dbb4f951a44ec1876e5b5ee/src/Queue/TenantAwareJob.php). I had to heavily modify it for my own multi tenancy solution but it basically looked like:
<?php
/**
* Serialization overrides to save and set tenant on sleep/wakeup
*/
namespace App\Lib\Queue;
use Illuminate\Queue\SerializesModels;
trait TenantAwareJob
{
protected $tenant;
use SerializesModels {
__sleep as serializedSleep;
__wakeup as serializedWakeup;
}
public function __sleep()
{
$this->tenant = getTenant(); //a global helper I've created for getting the currently selected tenant schema
$attributes = $this->serializedSleep();
return $attributes;
}
public function __wakeup()
{
setTenant($this->tenant); //a global helper I've created for setting the tenant schema
$this->serializedWakeup();
}
}```