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]);
    }