/** * Compile the routes into a displayable format. * * @return array */ protected function getRoutes() { $results = []; foreach ($this->routes as $route) { $results[] = $this->getRouteInformation(collect($route)); } if ($sort = $this->option('sort')) { $results = Arr::sort($results, function ($value) use($sort) { return $value[$sort]; }); } if ($this->option('reverse')) { $results = array_reverse($results); } return array_filter($results); }
static function toArray() { $ret = []; foreach (static::$groups as $name => $group) { if (!isset(static::$groups_priority[$name])) { static::$groups_priority[$name] = 0; } } static::$groups_priority = Arr::sort(static::$groups_priority, function ($v) { return -$v; }); foreach (static::$groups_priority as $name => $p) { $group = Arr::get(static::$groups, $name); $ret[$name] = $group->toArray(); } return $ret; }
/** * Compile the routes into a displayable format. * * @return array */ protected function getRoutes() { $routes = []; foreach ($this->routes as $collection) { foreach ($collection->getRoutes() as $route) { $routes[] = $this->filterRoute(['host' => $route->domain(), 'uri' => implode('|', $route->methods()) . ' ' . $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'protected' => $this->routeHasAuthMiddleware($route) ? 'Yes' : 'No', 'versions' => implode(', ', $route->versions()), 'scopes' => implode(', ', $route->scopes())]); } } if ($sort = $this->option('sort')) { $routes = Arr::sort($routes, function ($value) use($sort) { return $value[$sort]; }); } if ($this->option('reverse')) { $routes = array_reverse($routes); } return array_filter(array_unique($routes, SORT_REGULAR)); }
/** * Compile the routes into a displayable format. * * @return array */ protected function getRoutes() { $routes = []; foreach ($this->router->getRoutes() as $collection) { foreach ($collection->getRoutes() as $route) { $routes[] = $this->filterRoute(['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'protected' => $route->isProtected() ? 'Yes' : 'No', 'versions' => implode(', ', $route->versions()), 'scopes' => implode(', ', $route->scopes()), 'rate' => $this->routeRateLimit($route)]); } } if ($sort = $this->option('sort')) { $routes = Arr::sort($routes, function ($value) use($sort) { return $value[$sort]; }); } if ($this->option('reverse')) { $routes = array_reverse($routes); } if ($this->option('short')) { $this->headers = ['Method', 'URI', 'Name', 'Version(s)']; $routes = array_map(function ($item) { return array_only($item, ['method', 'uri', 'name', 'versions']); }, $routes); } return array_filter(array_unique($routes, SORT_REGULAR)); }
/** * Sort the array using the given callback. * * @param array $array * @param callable $callback * @return array */ function array_sort($array, callable $callback) { return Arr::sort($array, $callback); }
/** * Sort the array using the given Closure. * * @param array $array * @param \Closure $callback * @return array */ function array_sort($array, Closure $callback) { return Arr::sort($array, $callback); }