protected function provideAPIRoutes()
    {
        $routes = Cache::rememberForever('provideAPIRoutes', function () {
            $router = app(Router::class);
            $routes = [];
            foreach ($router->getRoutes() as $collection) {
                foreach ($collection->getRoutes() as $route) {
                    $temp = &$routes;
                    if ($routeName = $route->getName()) {
                        foreach (explode('.', $routeName) as $key) {
                            $temp = &$temp[$key];
                        }
                        $temp = preg_replace('/{(\w+)}/', ':$1', $route->uri());
                    }
                }
            }

            return $routes['api'];
        });

        JavaScript::put(['api' => $routes]);
    }
protected function provideAPIRoutes()
    {
        $routes = Cache::rememberForever('provideAPIRoutes', function () {
            $router = app(Router::class);
            $routes = [];
            foreach ($router->getRoutes() as $collection) {
                foreach ($collection->getRoutes() as $route) {
                    $temp = &$routes;
                    if ($routeName = $route->getName()) {
                        foreach (explode('.', $routeName) as $key) {
                            $temp = &$temp[$key];
                        }
                        $temp = preg_replace('/{(\w+)}/', ':$1', $route->uri());
                    }
                }
            }

            return $routes['api'];
        });

        JavaScript::put(['api' => $routes]);
    }
protected function provideAPIRoutes ( ) { $ routes = Cache :: rememberForever ( 'provideAPIRoutes' , function ( ) { $ router = app ( Router :: class ) ; $ routes = [ ] ; foreach ( $ router -> getRoutes ( ) as $ collection ) { foreach ( $ collection -> getRoutes ( ) as $ route ) { $ temp = & $ routes ; if ( $ routeName = $ route -> getName ( ) ) { foreach ( explode ( '.' , $ routeName ) as $ key ) { $ temp = & $ temp [ $ key ] ; } $ temp = preg_replace ( '/{(\w+)}/' , ':$1' , $ route -> uri ( ) ) ; } } } return $ routes [ 'api' ] ; } ) ; JavaScript :: put ( [ 'api' => $ routes ] ) ; }
Provide all api routes as javascript variables.
Provide all api routes as javascript variables .