Some models are provided by packages, and sometimes even my own. But for argument's sake take for example:
- I have installed Laravel telescope for each of my tenants, but I also want to use it in the central domain. How I can I do that? My code below:
class ConfigureTenantModels
{
protected $models = [
'passportClient' => Client::class,
'passportToken' => Token::class,
'passportAuthCode' => AuthCode::class,
'passportAccessClient' => PersonalAccessClient::class,
'spattieRole' => Role::class,
'spattiePermission' => Permission::class,
'telescopeEntryModel' => EntryModel::class,
];
public function handle(ConfigureModels $event)
{
if ($event->event->tenant) {
foreach ($this->models as $model) {
ConfigureModels::setConnectionResolver($model, new ConnectionResolver('tenant', resolve('db')));
}
}
}
}
The problem with the above approach is they tend to use tenant connection. How I can be able to switch the Telescope model to switch to the central website connection whenever user navigate to central.com from user.central.com? Regardless of whether the user is logged in or not?