File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/KommaApp/Shop/Domain.php
<?php
namespace KommaApp\Shop;
use KommaApp\Shop\Shops\Models\Domain as DomainModel;
class Domain
{
protected $domain;
protected $defaultLanguage = 'nl';
public function __construct()
{
switch (\Request::server('HTTP_HOST')) {
//German test domain
case 'topskwl.localhost:8000':
case 'topskwl.komma.pro':
case 'www.topskwl.komma.pro':
$domain = 'topskwl.komma.pro';
break;
//Dutch test domain
case 'www.topswtw.komma.pro':
case 'topswtw.komma.pro':
$domain = 'topswtw.komma.pro';
break;
//Belgian Test domain
case 'topsbe.local':
case 'topsbe.komma.pro':
case 'www.topsbe.komma.pro':
$domain = 'topswtwfilters.be';
break;
//Austrian Domain
case 'topskwlfilter.at':
case 'www.topskwlfilter.at':
$domain = 'topskwlfilter.at';
break;
//German domain
case 'topskwlfilter.de':
case 'www.topskwlfilter.de':
$domain = 'topskwlfilter.de';
break;
//Belgian domain
case 'topswtwfilters.be':
case 'www.topswtwfilters.be':
$domain = 'topswtwfilters.be';
break;
case 'topsmvhrfilters.com':
case 'www.topsmvhrfilters.com':
$domain = 'topsmvhrfilters.com';
break;
//By default the dutch shop is chosen
default:
$domain = 'topswtwfilters.nl';
}
$this->domain = DomainModel::Where('domain', '=', $domain)->with('country')->first();
}
/**
* This method will return the domain string
*
* @return Domain string
*/
public function get()
{
return $this->domain->domain;
}
public function getCountry($field = 'iso_2')
{
return $this->domain->country->$field;
}
public function getLinkedDomains()
{
$linkedDomains = [];
switch ($this->get()) {
case 'topskwlfilter.at':
$linkedDomains = ['topskwlfilter.de'];
break;
case 'topskwlfilter.de':
$linkedDomains = ['topskwlfilter.at'];
break;
case 'topswtwfilters.be':
$linkedDomains = ['topswtwfilters.nl'];
break;
case 'topswtwfilters.nl':
$linkedDomains = ['topswtwfilters.be'];
break;
}
$domains[] = $this->domain;
foreach ($linkedDomains as $linkedDomain) {
if (!$domain = $this->getDomain($linkedDomain)) contine;
$domains[] = $domain;
}
return $domains;
}
function getDomain($domain)
{
return DomainModel::Where('domain', '=', $domain)->with('country')->first();
}
}