root()); $site = Site::where('domain', $domain)->first(); if ($site) { return $site->user_template->business; } elseif (in_array($domain, static::$mainDomains)) { if ( \AuthFinder::check() && \AuthFinder::user()->last_used_business !== 0) { return Business::findOrFail(\AuthFinder::user()->last_used_business); } throw new VirtualActivityNotFoundException('Business Not Found'); } throw new SiteNotFoundException('Site Not Found'); } /** * finds site name based on specified url address. * * @param string $domain * @return Business */ public static function findSiteName($domain) { $array = explode('.', parse_url($domain, PHP_URL_HOST)); if (count($array) == 4) { $domain = $array[1]; } elseif (count($array) == 3) { if ($array[0] === 'www') { $domain = $array[1] . '.' . $array[2]; } else { $domain = $array[0]; } } elseif (count($array) == 2) { $domain = $array[0] . '.' . $array[1]; } return $domain; } }