mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54:03 +00:00
merge 1.x
This commit is contained in:
commit
4d64542ce1
6 changed files with 84 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ use Stancl\Tenancy\Commands\Seed;
|
|||
use Illuminate\Cache\CacheManager;
|
||||
use Stancl\Tenancy\Commands\Install;
|
||||
use Stancl\Tenancy\Commands\Migrate;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Commands\Rollback;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
|
@ -52,6 +53,8 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
if (\class_exists(Telescope::class)) {
|
||||
$this->setTelescopeTags();
|
||||
}
|
||||
|
||||
$this->registerTenantRedirectMacro();
|
||||
}
|
||||
|
||||
public function setTelescopeTags()
|
||||
|
|
@ -75,6 +78,19 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
});
|
||||
}
|
||||
|
||||
public function registerTenantRedirectMacro()
|
||||
{
|
||||
RedirectResponse::macro('tenant', function (string $domain) {
|
||||
// replace first occurance of hostname fragment with $domain
|
||||
$url = $this->getTargetUrl();
|
||||
$hostname = \parse_url($url, PHP_URL_HOST);
|
||||
$position = \strpos($url, $hostname);
|
||||
$this->setTargetUrl(\substr_replace($url, $domain, $position, \strlen($hostname)));
|
||||
|
||||
return $this;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue