added url::home

This commit is contained in:
Taylor Otwell 2012-02-15 08:27:10 -06:00
parent 75280a9fea
commit 188394bae1
2 changed files with 22 additions and 11 deletions

View File

@ -11,17 +11,7 @@ class Redirect extends Response {
*/ */
public static function home($status = 302, $https = false) public static function home($status = 302, $https = false)
{ {
$route = Router::find('home'); return static::to(URL::home($https), $status);
// 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);
} }
/** /**

View File

@ -29,6 +29,27 @@ public static function current()
return static::to(URI::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. * Get the base URL of the application.
* *