Exemplo n.º 1
0
 /**
  * Test the Router::find method.
  *
  * @group laravel
  */
 public function testNamedRoutesCanBeLocatedByTheRouter()
 {
     Route::get('/', array('as' => 'home'));
     Route::get('dashboard', array('as' => 'dashboard'));
     $home = Router::find('home');
     $dashboard = Router::find('dashboard');
     $this->assertTrue(isset($home['/']));
     $this->assertTrue(isset($dashboard['dashboard']));
 }
Exemplo n.º 2
0
 /**
  * Get the URL for the application root.
  *
  * @param  bool    $https
  * @return string
  */
 public static function home($https = null)
 {
     $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);
 }
Exemplo n.º 3
0
 public static function to_route($name, $parameters = array())
 {
     if (is_null($route = Routing\Router::find($name))) {
         throw new \Exception("Error creating URL for undefined route [{$name}].");
     }
     $https = array_get(current($route), 'https', null);
     $uri = trim(static::transpose(key($route), $parameters), '/');
     return static::to($uri, $https);
 }
Exemplo n.º 4
0
 /**
  * Generate a URL from a route name.
  *
  * <code>
  *		// Create a URL to the "profile" named route
  *		$url = URL::to_route('profile');
  *
  *		// Create a URL to the "profile" named route with wildcard parameters
  *		$url = URL::to_route('profile', array($username));
  * </code>
  *
  * @param  string  $name
  * @param  array   $parameters
  * @return string
  */
 public static function to_route($name, $parameters = array())
 {
     if (is_null($route = Routing\Router::find($name))) {
         throw new \Exception("Error creating URL for undefined route [{$name}].");
     }
     // To determine whether the URL should be HTTPS or not, we look for the "https"
     // value on the route action array. The route has control over whether the URL
     // should be generated with an HTTPS protocol string or just HTTP.
     $https = array_get(current($route), 'https', null);
     $uri = trim(static::transpose(key($route), $parameters), '/');
     return static::to($uri, $https);
 }
Exemplo n.º 5
0
 public static function home($https = null)
 {
     $route = Router::find('home');
     if (!is_null($route)) {
         return static::to_route('home');
     }
     return static::to('/', $https);
 }