本文整理汇总了PHP中Illuminate\Support\Facades\Request::getHttpHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getHttpHost方法的具体用法?PHP Request::getHttpHost怎么用?PHP Request::getHttpHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::getHttpHost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeInternalLinksRelative
/**
* Make links which include the current HTTP host relative, even if the scheme doens't match.
*
* Internal links within text are stored as relative links so that if a site moves host
* or the database is copied to another site (e.g. development or staging versions)
* the links will still work correctly.
*
* @param string $text
*
* @return string
*/
public static function makeInternalLinksRelative($text)
{
if ($base = Request::getHttpHost()) {
return preg_replace("|<(.*?)href=(['\"])(https?://)" . $base . "/(.*?)(['\"])(.*?)>|", '<$1href=$2/$4$5$6>', $text);
}
return $text;
}
示例2: factory
public static function factory($link)
{
$link = preg_replace('|^https?://' . Request::getHttpHost() . '|', '', $link);
if (is_int($link) || ctype_digit($link) || substr($link, 0, 1) == '/') {
$internal = new Internal($link);
// If it's not a valid CMS URL then it's a relative URL which isn't CMS managed so treat it as an external URL.
return $internal->isValidPage() ? $internal : new External($link);
} else {
return new External($link);
}
}
示例3: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
// Are we connecting from a known URL?
if ($airline = Airline::where('url', '=', Request::getHttpHost())->first()) {
Session::put('airlineId', $airline->id);
}
if (Session::has('airlineId')) {
$view->with('airline', Airline::find(Session::get('airlineId')));
}
if (Request::user()) {
$view->with('user', Request::user());
$view->with('pilot', PilotRepository::getCurrentPilot());
$airline = Airline::find(Session::get('airlineId'));
$view->with('airlineStaff', UserRepository::hasRole($airline->prefix . '-staff', Request::user()));
}
}
示例4: makeRelative
public static function makeRelative($url)
{
return ($base = Request::getHttpHost()) ? str_replace(Request::getScheme() . $base, '/', $url) : $url;
}
示例5: makeRelative
public static function makeRelative($url)
{
return preg_replace('|^https?://' . Request::getHttpHost() . '|', '', $url);
}