Illuminate\Routing\UrlGenerator::getRootUrl PHP Method

getRootUrl() protected method

Get the base URL for the request.
protected getRootUrl ( string $scheme, string $root = null ) : string
$scheme string
$root string
return string
    protected function getRootUrl($scheme, $root = null)
    {
        if (is_null($root)) {
            if (is_null($this->cachedRoot)) {
                $this->cachedRoot = $this->forcedRoot ?: $this->request->root();
            }
            $root = $this->cachedRoot;
        }
        $start = Str::startsWith($root, 'http://') ? 'http://' : 'https://';
        return preg_replace('~' . $start . '~', $scheme, $root, 1);
    }

Usage Example

 protected function newGetRootUrl($scheme, $root = null)
 {
     if ($root == null) {
         $root = parent::getRootUrl($scheme) . (defined('LARAVEL_SHARED') ? '/public' : '');
     }
     return parent::getRootUrl($scheme, $root);
 }