Resolve and return the model class for requests.

@param \Illuminate\Routing\Route $route
@return string
324559
public function resolveModelClass(Route $route): string
	{
		// The plural resource name is always the second URL segment, after the API version
		$route_name = $route->getName();

		if (! is_null($route_name) && strpos($route_name, '.') !== false) {
			list(, $alias) = array_reverse(explode('.', $route->getName()));

			$model_class = $this->namespaceModel(Str::studly(Str::singular($alias)));

			if (is_a($model_class, MagicBoxResource::class, true)) {
				return $model_class;
			}

			throw new \LogicException(sprintf('%s must be an instance of %s', $model_class, MagicBoxResource::class));
		}

		throw new \LogicException('Unable to resolve model from improperly named route');
	}
377354
private function resolveController($route, $path)
    {
        $pathComponents = explode('/', $path);
        $baseClassPath = $this->config->getClassPath($route);

        $classObject = null;
        $aliases = $this->config->getAliases($route);

        $class = $baseClassPath;
        $classAlias = '';

        $controllerFactory = $this->config->getControllerFactory();
        $routeConfig = [];

        $routes = $this->config->getRoutes();
        if (is_array($routes) && isset($routes[$route]['config'])) {
            $routeConfig = $routes[$route]['config'];
        }

        while ($pathComponents) {
            $pathComponent = array_shift($pathComponents);

            $class = $class.'\\'.ucfirst($pathComponent);
            $classAlias .= ucfirst($pathComponent);

            // check for an alias first
            if (isset($aliases[strtolower($classAlias)])) {
                $aliasClass = $baseClassPath.'\\'.$aliases[strtolower($classAlias)];

                if (class_exists($aliasClass)) {
                    $classObject = $controllerFactory($aliasClass, $routeConfig);
                    break;
                }
            }

            if (class_exists($class)) {
                $classObject = $controllerFactory($class, $routeConfig);

                if (!$classObject) {
                    $classObject = new $class();
                    break;
                }

                break;
            }

            $classAlias .= '/';
        }

        if (!$classObject) {
            throw new \Exception('API: No controller found for the requested end point. ');
        }

        // any path left over becomes args
        $pathArgs = $pathComponents;

        return [$classObject, array_shift($pathArgs), $pathArgs];
    }
1256773
public function extractRoutePath(string $route)
    {
        $url = (strpos($route, '/') === false) ? url($route) : $route;
        $this->router->handle($url);

        return $this->router->getMatchedRoute()->getPaths();
    }
23195
private function getDomainRegex($route)
    {
        ReflectionHelper::invokePrivateMethod($route, 'compileRoute');
        $compiledRoute = ReflectionHelper::readPrivateProperty($route, 'compiled');

        return $compiledRoute->getHostRegex();
    }
612457
public function getRouteMiddleware($route)
    {
        return collect($route->gatherMiddleware())->map(function ($middleware) {
            return $middleware instanceof Closure ? 'Closure' : $middleware;
        })->implode(',');
    }
203367
static public function getRoutePatternParts( Route $route ){
		$parts	= array();
		foreach( explode( "/", $route->getPattern() ) as $part ){
			$optional	= FALSE;
			$argument	= FALSE;
			if( preg_match( "@\(:.+\)@", $part ) ){													//  optional argument found
				$part		= substr( $part, 1, -1 );												//  cut argument key
				$optional	= TRUE;																	//  note that is optional
			}
			if( substr( $part, 0, 1 ) === ":" ){													//  argument found
				$part		= substr( $part, 1 );													//  cut argument key
				$argument	= TRUE;																	//  note that is argument
			}
			$parts[]	= (object) array(															//  prepare route pattern part object
				'key'		=> $part,
				'optional'	=> $optional,
				'argument'	=> $argument,
			);
		}
		return $parts;
	}
213165
public function inflect(Route $route)
    {
        $arguments = $this->extractAttributes($route);
        return $this->createDispatch($arguments);
    }
1133413
protected function adminController($route = null)
    {
        if ($route) {
            return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController@'.$route;
        }

        return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController';
    }
916463
protected function getBeforeFilters($route)
	{
		$before = array_keys($route->beforeFilters());

		$before = array_unique(array_merge($before, $this->getPatternFilters($route)));

		return implode(', ', $before);
	}
861046
private function getMethods(Route $route)
    {
        $methods = $route->getMethods();
        sort($methods);

        return implode('|', $methods) ?: 'ANY';
    }
204463
public function routeClass($routeClass = null)
    {
        deprecationWarning(
            'RouteBuilder::routeClass() is deprecated. ' .
            'Use RouteBuilder::setRouteClass()/getRouteClass() instead.'
        );
        if ($routeClass === null) {
            return $this->getRouteClass();
        }
        $this->setRouteClass($routeClass);
    }
199633
private function guessControllerClass($routeController)
    {
        $temp = explode(':', $routeController);
        if (3 === count($temp)) {
            $controllerClass = $temp[0];
        } else {
            $controllerClass = get_class($this->container->get($temp[0]));
        }

        return $controllerClass;
    }
1022150
public function get($route)
    {
        $this->ensureStorage();

        return isset($this->storage[$route]) ? $this->storage[$route] : null;
    }
963941
public function getResourceConfigurationFromRequest($route)
    {
        // get just the base url without query string
        $route = parse_url($route, PHP_URL_PATH);

        // remove any slashes from begining/end
        $route = trim($route, " /");

        // get the base resource excluding any single identifiers
        $parts = explode('/', $route);
        $resource = is_numeric(end($parts)) ? prev($parts):end($parts);

        return $this->resourceConfigurationFor($resource);
    }
53855
public function getRouteName($route)
    {
        if (!$this->routePath) {
            // Grab route_prefix config first. If it's not set,
            // grab the resources, and replace `\` with `.`, and
            // transform it all to lowercase.
            $this->routePath = $this->getConfig('route_prefix')
                ?: str_replace('\\', '.', strtolower($this->getConfig('resources')));
        }
        return "{$this->routePath}.v{$this->current}" . str_after($route, $this->routePath);
    }
342693
protected function getRouteControllerDocBlock($route)
	{
		$routeAction = $route->getAction();
		list($class, $method) = explode('@', $routeAction['uses']);

		$reflectionClass = new ReflectionClass($class);

		$comment = $reflectionClass->getDocComment();

		if ($comment) {
			return($this->docBlockFactory->create($comment));
		}

		return null;
	}
1129838
public function getMethodsByRoute($route)
    {
        // Check if a route was provided
        if (!$route) {
            return [];
        }

        // Loop through our routes
        $methods = [];
        foreach ($this->routes as $method => $routes) {
            foreach ($routes as $availableRoute => $callable) {
                // Check if the available route is the same as the specified route
                if ($availableRoute === $route) {
                    $methods[] = $method;
                    continue 2;
                }

                // Check if the route matches
                $regex = '/^' . str_replace('/', '\/', $availableRoute) . '/Uim';
                if (preg_match($regex, $route, $matches) === 1 && $matches[0] === $route) {
                    $methods[] = $method;
                    continue 2;
                }
            }
        }

        // Return the methods array
        return $methods;
    }