diff --git a/src/Illuminate/Routing/AbstractRouteCollection.php b/src/Illuminate/Routing/AbstractRouteCollection.php index 0c59a555009e..6efc3875e09c 100644 --- a/src/Illuminate/Routing/AbstractRouteCollection.php +++ b/src/Illuminate/Routing/AbstractRouteCollection.php @@ -202,18 +202,20 @@ public function toSymfonyRouteCollection() { $symfonyRoutes = new SymfonyRouteCollection; - $routes = $this->getRoutes(); + $fallbackRoutes = []; - foreach ($routes as $route) { - if (! $route->isFallback) { - $symfonyRoutes = $this->addToSymfonyRoutesCollection($symfonyRoutes, $route); + foreach ($this->getRoutes() as $route) { + if ($route->isFallback) { + $fallbackRoutes[] = $route; + + continue; } + + $symfonyRoutes = $this->addToSymfonyRoutesCollection($symfonyRoutes, $route); } - foreach ($routes as $route) { - if ($route->isFallback) { - $symfonyRoutes = $this->addToSymfonyRoutesCollection($symfonyRoutes, $route); - } + foreach($fallbackRoutes as $route) { + $symfonyRoutes = $this->addToSymfonyRoutesCollection($symfonyRoutes, $route); } return $symfonyRoutes;