/**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param string                   $type
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $type)
 {
     if (!$this->typeResolver->hasType($this->tenant->getTenantCreator(), $type)) {
         return redirect()->route('tenant.tenant_type_not_supported', ['type' => $type]);
     }
     return $next($request);
 }
 /**
  * @param string $path
  * @param array  $parameters
  */
 protected function ensureTenancyInParameters($path, &$parameters)
 {
     if (stripos($path, 'tenant_owner_id') !== false && !isset($parameters['tenant_owner_id'])) {
         $parameters['tenant_owner_id'] = $this->tenant->getTenantOwnerId();
     }
     if (stripos($path, 'tenant_creator_id') !== false && !isset($parameters['tenant_creator_id'])) {
         $parameters['tenant_creator_id'] = $this->tenant->getTenantCreatorId();
     }
 }
 /**
  * @param QueryBuilder $qb
  * @param string       $alias
  */
 protected function applyClosedSecurityModel(QueryBuilder $qb, $alias)
 {
     $qb->where("{$alias}.tenantOwnerId = :tenantOwnerId")->andWhere("{$alias}.tenantCreatorId = :tenantCreatorId")->setParameters([':tenantOwnerId' => $this->tenant->getTenantOwnerId(), ':tenantCreatorId' => $this->tenant->getTenantCreatorId()]);
 }
 /**
  * @param TenantContract $tenant
  *
  * @return $this
  */
 public function importTenancyFrom(TenantContract $tenant)
 {
     $this->setTenantOwnerId($tenant->getTenantOwnerId());
     $this->setTenantCreatorId($tenant->getTenantCreatorId());
     return $this;
 }