Example #1
0
 /**
  * Take all routes from a file and add it to RouteCollection.
  *
  * @param string $filePath
  *
  * @return void
  */
 public function addRoutesFromFile($filePath)
 {
     // Collect the routes
     collect(Yaml::parse(file_get_contents($filePath)))->transform(function ($routesDetails, $method) {
         $routesDetails = collect($routesDetails);
         return new Route(strtoupper($method), $routesDetails->get('path'), $routesDetails->forget('path')->all());
     })->values()->each(function ($route) {
         $this->routes->placeRoute($route);
     });
 }
Example #2
0
 /**
  * Test we can place a Route object in the RouteCollection.
  *
  * @return void
  */
 public function testAddRouteToCollection()
 {
     $this->routeCollection->placeRoute(new Route('GET', '/foobar', ['uses' => 'AcmeController::index', 'as' => 'foo.bar']));
     $this->assertCount(1, $this->routeCollection);
 }