mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:54:04 +00:00
41 lines
895 B
PHP
41 lines
895 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Middleware;
|
|
|
|
use Closure;
|
|
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
|
use Stancl\Tenancy\Tenancy;
|
|
|
|
class InitializeTenancyByDomain extends IdentificationMiddleware
|
|
{
|
|
/** @var callable|null */
|
|
public static $onFail;
|
|
|
|
/** @var Tenancy */
|
|
protected $tenancy;
|
|
|
|
/** @var DomainTenantResolver */
|
|
protected $resolver;
|
|
|
|
public function __construct(Tenancy $tenancy, DomainTenantResolver $resolver)
|
|
{
|
|
$this->tenancy = $tenancy;
|
|
$this->resolver = $resolver;
|
|
}
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
return $this->initializeTenancy(
|
|
$request, $next, $request->getHost()
|
|
);
|
|
}
|
|
}
|