mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 09:34:04 +00:00
* install PHP CS Fixer * Fix styling * remove StyleCI config * use config from archtechx/template * Fix styling * added `php-cs-fixer` * Update .php-cs-fixer.php * added GitHub token * Update ci.yml * Update ci.yml * Update ci.yml * php-cs-fixer workflow same as template Co-authored-by: Erik Gaal <me@erikgaal.nl> Co-authored-by: erikgaal <erikgaal@users.noreply.github.com>
30 lines
731 B
PHP
30 lines
731 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Support\Str;
|
|
|
|
class InitializeTenancyByDomainOrSubdomain
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
if ($this->isSubdomain($request->getHost())) {
|
|
return app(InitializeTenancyBySubdomain::class)->handle($request, $next);
|
|
} else {
|
|
return app(InitializeTenancyByDomain::class)->handle($request, $next);
|
|
}
|
|
}
|
|
|
|
protected function isSubdomain(string $hostname): bool
|
|
{
|
|
return Str::endsWith($hostname, config('tenancy.central_domains'));
|
|
}
|
|
}
|