From 188394bae13b23e757aed826c959033c1dede8e7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 15 Feb 2012 08:27:10 -0600 Subject: [PATCH] added url::home --- laravel/redirect.php | 12 +----------- laravel/url.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/laravel/redirect.php b/laravel/redirect.php index e8c45f1e..2ba9502b 100644 --- a/laravel/redirect.php +++ b/laravel/redirect.php @@ -11,17 +11,7 @@ class Redirect extends Response { */ public static function home($status = 302, $https = false) { - $route = Router::find('home'); - - // If a route named "home" exists, we'll route to that instead of using - // the single slash root URI. THis allows the HTTPS attribute to be - // respected instead of being hard-coded in the redirect. - if ( ! is_null($route)) - { - return static::to_route('home', $status); - } - - return static::to('/', $status, $https); + return static::to(URL::home($https), $status); } /** diff --git a/laravel/url.php b/laravel/url.php index 55cce516..6c63c89e 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -29,6 +29,27 @@ public static function current() return static::to(URI::current()); } + /** + * Get the URL for the application root. + * + * @param bool $https + * @return string + */ + public static function home($https = false) + { + $route = Router::find('home'); + + // If a route named "home" exists, we'll route to that instead of using + // the single slash root URI. THis allows the HTTPS attribute to be + // respected instead of being hard-coded in the redirect. + if ( ! is_null($route)) + { + return static::to_route('home'); + } + + return static::to('/', $https); + } + /** * Get the base URL of the application. *