Flatten the routes

@param array		$routes
@param string		$param_prefix
@return array
973471
protected static function flatten( $routes, $param_prefix = '' ) 
	{
		
		$flattened = array();
		
		foreach( $routes as $prefix => $route ) 
		{
			if ( is_array( $route ) && !is_callable( $route ) ) 
			{
				$flattened = array_merge( static::flatten( $route, $param_prefix.$prefix.'/' ), $flattened );
			} 
			else 
			{
				if ( $prefix == '/' ) 
				{
					$prefix = ''; $param_prefix = substr( $param_prefix, 0, -1 );
					$flattened[$param_prefix.$prefix] = $route;
					$param_prefix.= '/';
				} 
				else 
				{
					$flattened[$param_prefix.$prefix] = $route;
				}
			}
		}
		
		return $flattened;
	}
813851
public function route($route, $params = [])
    {
        $this->url(
            $this->container->make('url')->route($route, $params)
        );

        return $this;
    }
663241
public static function flattenArrayToString($params = array())
    {
        $string = '';
        if (!empty($params)) {
            ob_start();
            print_r($params);
            $string = @ob_get_clean();
            @ob_end_clean();
        }

        return $string;
    }
1262296
protected function getPrefixes()
    {
        $router = app(\Illuminate\Routing\Router::class);

        $this->prefixes = collect(
            explode('/', $router->getCurrentRoute()->getPrefix())
        );

        // Remove the last prefix if it matches the controller.
        $this->prefixes = $this->removeControllerFromPrefixes($this->prefixes)->filter();

        if ($this->prefixes->count() > 0) {
            $this->prefix = $this->prefixes->filter()->implode('.');
        }
    }
662554
public function filterPrefix($prefix)
    {
        $names = [];

        foreach ($this->getMethods() as $method) {
            if ($method->isPublic() && substr_count($method->getName(), $prefix, null, strlen($prefix))) {
                $names[] = $method->getName();
            }
        }

        return $names;
    }
364883
protected function _routerPrefixes()
    {
        $cache = static::cache('_routerPrefixes');
        if (!$cache) {
            $prefixes = [];
            foreach (Router::routes() as $route) {
                if (empty($route->defaults['prefix'])) {
                    continue;
                } else {
                    $prefix = Inflector::camelize($route->defaults['prefix']);
                    if (!in_array($prefix, $prefixes)) {
                        $prefixes[] = $prefix;
                    }
                }
            }

            $cache = static::cache('_routerPrefixes', $prefixes);
        }

        return $cache;
    }
957775
private function prefixPaths (array $paths, string $prefix) : array
    {
        $result = [];

        foreach ($paths as $namespace => $path)
        {
            $result[$namespace] = "{$prefix}/" . trim($path, "/");
        }

        return $result;
    }
874762
private function parseRoutes(Collection $routes) : array
    {
        $parsedRoutes = [];
        foreach ($routes as $route) {
            $routeUrl = strtr($route->getUrl(), $this->regexShortcuts);

            list($routeRegex, $parameters) = $this->transformRoute($routeUrl);

            $parsedRoute = new Parsed($route);
            $parsedRoute->setPlaceholders($parameters);

            $parsedRoutes[] = [$routeRegex, $parsedRoute];
        }

        return $parsedRoutes;
    }
334245
protected function getClientParams( array $params, array $prefixes = array( 'f', 'l', 'd', 'a' ) )
	{
		$list = [];

		foreach( $params as $key => $value )
		{
			if( in_array( $key[0], $prefixes ) && $key[1] === '_' ) {
				$list[$key] = $value;
			}
		}

		return $list;
	}
767575
private function getRoutePrefix($routePrefix)
    {
        $prefixes = $this->getRoutePrefixes();
        
        return in_array($routePrefix, $prefixes) ? $routePrefix : array_shift($prefixes);
    }
1047867
final public function prefix($prefix)
    {
        if (\is_array($prefix)) {
            if (null === $this->parentPrefixes) {
                // no-op
            } elseif ($missing = array_diff_key($this->parentPrefixes, $prefix)) {
                throw new \LogicException(sprintf('Collection "%s" is missing prefixes for locale(s) "%s".', $this->name, implode('", "', array_keys($missing))));
            } else {
                foreach ($prefix as $locale => $localePrefix) {
                    if (!isset($this->parentPrefixes[$locale])) {
                        throw new \LogicException(sprintf('Collection "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $this->name, $locale));
                    }

                    $prefix[$locale] = $this->parentPrefixes[$locale].$localePrefix;
                }
            }
            $this->prefixes = $prefix;
            $this->route->setPath('/');
        } else {
            $this->prefixes = null;
            $this->route->setPath($prefix);
        }

        return $this;
    }
1207347
private function createMap(RouteCollectionInterface $routes)
    {
        $i    = 0;
        $m    = [];
        $rpl  = sprintf(self::NGRP_RPLC, Ps::EXP_DELIM);
        $expr = [];
        $pfx  = 'r'.time();
        $expr['prefix'] = $pfx;

        foreach ($routes->all() as $name => $route) {
            foreach ($route->getMethods() as $method) {
                $m[$method][$name] = $route;
            }
        }

        foreach ($m as $mn => $rts) {
            $mn = strtolower($mn);
            $expr[$mn]['map'] = [];
            $regex = [];

            foreach ($rts as $rn => $rt) {
                $ctx      = $rt->getContext();
                $index    = $pfx.'_'.$this->replaceRouteName($rn, $i);
                $ctxRegex = preg_replace($rpl, '$1r'.(string)$i.'_$2>', $ctx->getRegex(true));
                $regex[]  = sprintf('(?P<%s>%s)', $index, $ctxRegex);
                $expr[$mn]['map'][$index] = [$i, $rn, 'r'.$i.'_'];
                $i++;
            }

            $i = 0;
            $expr[$mn]['regex'] = sprintf('%1$s(?:^'.join('|', $regex).')$%1$sx', Ps::EXP_DELIM);
        }

        return $expr;
    }
912849
public function addRoutesFromArray(array $routes)
    {
        foreach ($routes as $name => $route) {
            $this->addRouteFromArray($name, $route);
        }
        return $this;
    }
305710
protected function flattenArray(array $body, $prefix = '')
    {
        $newBody = array();
        foreach ($body as $k => $v) {
            $key = (!strlen($prefix)) ? $k : "{$prefix}[{$k}]";
            if (is_array($v)) {
                $newBody += $this->flattenArray($v, $key);
            } else {
                $newBody[$key] = $v;
            }
        }
        return $newBody;
    }
689367
protected function headerLink(array $routes)
    {
        $links = [];
        foreach ($routes as $rel => $route) {
            $links[] = '<' . $this->url . $route . '>; rel="' . $rel . '"';
        }
        return implode(', ', $links);
    }
278542
final public static function removeEmptyData(array $routes):array
    {
        $c = count($routes);
        for ($i = 0; $i < $c; $i++) {
            if (trim($routes[$i]) == "" || $routes[$i] == null || empty($routes[$i])) {
                unset($routes[$i]);
            }
        }
        return ($routes);
    }
63663
public static function array_flatten_multidim($array, $prefix = false)
    {
        $return = array();
        if (is_array($array) || is_object($array)) {
            if (empty($array)) {
                $return[$prefix] = '';
            } else {
                foreach ($array as $key => $value) {
                    if (is_scalar($value)) {
                        if ($prefix) {
                            $return[$prefix . '[' . $key . ']'] = $value;
                        } else {
                            $return[$key] = $value;
                        }
                    } else {
                        if ($value instanceof \CURLFile) {
                            $return[$key] = $value;
                        } else {
                            $return = array_merge(
                                $return, self::array_flatten_multidim(
                                    $value, $prefix ? $prefix . '[' . $key . ']' : $key));
                        }
                    }
                }
            }
        } elseif ($array === null) {
            $return[$prefix] = $array;
        }
        return $return;
    }