1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:14:04 +00:00

Add exempt domains

This commit is contained in:
Samuel Štancl 2019-01-19 14:49:42 +01:00
parent eaeeeb5046
commit 7b95a9a4cd
2 changed files with 11 additions and 2 deletions

View file

@ -8,7 +8,9 @@ class InitializeTenancy
{ {
public function __construct(Closure $onFail = null) public function __construct(Closure $onFail = null)
{ {
$this->onFail = $onFail ?: function ($e) { throw $e; }; $this->onFail = $onFail ?: function ($e) {
throw $e;
};
} }
/** /**
@ -20,8 +22,12 @@ class InitializeTenancy
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (in_array($request->getHost(), config('tenancy.exempt_domains', []))) {
return $next($request);
}
try { try {
tenancy()->init(); tenancy()->init();
} catch (\Exception $e) { } catch (\Exception $e) {
// Pass the exception to the onFail function if it takes any parameters. // Pass the exception to the onFail function if it takes any parameters.
$callback = $this->onFail; $callback = $this->onFail;

View file

@ -2,6 +2,9 @@
return [ return [
'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver', 'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver',
'exempt_domains' => [
// 'localhost',
],
'database' => [ 'database' => [
'based_on' => 'mysql', 'based_on' => 'mysql',
'prefix' => 'tenant', 'prefix' => 'tenant',