Created
November 25, 2017 21:36
-
-
Save argentinaluiz/09de290706f2ad8f04bc893b7b3abaeb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Tenant; | |
class TenantManager | |
{ | |
private $tenant; //instancia de account | |
//substituir o routeParama | |
public function tenantParam(){ | |
$domain = url('/'); | |
$domainParts = parse_url($domain); | |
$host = $domainParts['host']; | |
return explode(".",$host)[1]; //pegando a primeira parte do domínio) | |
} | |
//substituir o isSubdomainExcept | |
public function isDomainExcept(){ | |
$tenantParam = $this->tenantParam(); | |
return $tenantParam && in_array($tenantParam,config('tenant.domains_except')) //substituir o tenant.domains_except | |
?true:false; | |
} | |
public function getTenant(){ | |
if(!$this->tenant){ | |
$model = config('tenant.model'); | |
$this->tenant = $model | |
::where(config('tenant.field_name'),$this->tenantParam()) | |
->first(); | |
} | |
return $this->tenant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment