mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:54:03 +00:00
Add ScoutTenancyBootstrapper
This commit is contained in:
parent
020039bf89
commit
d2403cea38
1 changed files with 35 additions and 0 deletions
35
src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php
Normal file
35
src/Bootstrappers/Integrations/ScoutTenancyBootstrapper.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Bootstrappers\Integrations;
|
||||
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
|
||||
class ScoutTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
/** @var Repository */
|
||||
protected $config;
|
||||
|
||||
/** @var string */
|
||||
protected $originalScoutPrefix;
|
||||
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function bootstrap(Tenant $tenant)
|
||||
{
|
||||
if (! isset($this->originalScoutPrefix)) {
|
||||
$this->originalScoutPrefix = $this->config->get('scout.prefix');
|
||||
}
|
||||
|
||||
$this->config->set('scout.prefix', $tenant->getTenantKey());
|
||||
}
|
||||
|
||||
public function revert()
|
||||
{
|
||||
$this->config->set('scout.prefix', $this->originalScoutPrefix);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue