diff --git a/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php new file mode 100644 index 00000000..49869bb5 --- /dev/null +++ b/src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php @@ -0,0 +1,42 @@ +config = $config; + } + + public function bootstrap(Tenant $tenant) + { + if (! isset($this->originalScoutPrefix)) { + $this->originalScoutPrefix = $this->config->get('scout.prefix'); + } + + $this->config->set('scout.prefix', $this->getTenantPrefix($tenant)); + } + + public function revert() + { + $this->config->set('scout.prefix', $this->originalScoutPrefix); + } + + protected function getTenantPrefix(Tenant $tenant): string + { + return (string) $tenant->getTenantKey(); + } +}