Route a resource to a controller.

@param  string $name
@param  string $controller
@param  array $options
324222
public function register( $name, $controller, array $options = [] )
	{
		if ( isset( $options['parameters'] ) && !isset( $this->parameters ) )
			$this->parameters = $options['parameters'];

		// If the resource name contains a slash, we will assume the developer wishes to
		// register these resource routes with a prefix so we will set that up out of
		// the box so they don't have to mess with it. Otherwise, we will continue.
		if ( Str::contains( $name, '/' ) )
		{
			$this->prefixedResource( $name, $controller, $options );

			return;
		}

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route parameters, which should be the base resources.
		$base = $this->getResourceWildcard( last( explode( '.', $name ) ) );

		$defaults = $this->resourceDefaults;

		foreach ( $this->getResourceMethods( $defaults, $options ) as $m )
			$this->{'addResource' . ucfirst( $m )}( $name, $base, $controller, $options );
	}
293938
protected function form($name, array $options = [], array $data = [])
    {
        return \App::make('laravel-form-builder')->create($name, $options, $data);
    }
787442
public function attachData($data, $name, array $options = [])
    {
        return $this->laravelMessage->attachData($data, $name, $options);
    }
338907
public function post($name, $path, $controller = null)
    {
        $this->add('POST', $name, $path, $controller);
        return $this;
    }
87773
public function controller($name)
	{
		if(isset($this->_controllers[$name]) && ($controller = $this->_controllers[$name]))
		{
			$name = is_callable($controller)
				? new CallbackController($controller)
				: $controller
				;

			if(is_object($name))
				return $name;
		}

		if($this->_resolver)
			return $this->_resolver->resolve($name);

		throw new LookupException("No controller defined for route '$name'");
	}
154549
protected function addResourceUpdate($name, $base, $controller, $options)
    {
        $this->addPutResourceUpdate($name, $base, $controller, $options);

        return $this->addPatchResourceUpdate($name, $base, $controller);
    }
295036
public static function register($name, $path, $controller, $parameters, $options=array()) {
		static::$routes[$name] = new static($name, $path, $controller, $parameters, $options);
	}
1211508
public function findController($name)
	{
	    $allControllers = array_keys($this->controllers);
	    
	    $expr        = preg_replace_callback('{([^:]+|)}', function ($matches) {
	        return preg_quote($matches[1]) . '[^:]*';
	    }, $name);
	    
	    $controllers = preg_grep('{^' . $expr . '}', $allControllers);
	    
        if (empty($controllers) || count(preg_grep('{^' . $expr . '$}', $controllers)) < 1) {
            if (false !== $pos = strrpos($name, ':')) {
                $this->findControllerNamespace(substr($name, 0, $pos));
            }
            
            $message = sprintf('Controller "%s" is not defined.', $name);
            
            if ($alternatives = $this->findAlternatives($name, $allControllers)) {
                if (1 == count($alternatives)) {
                    $message .= "\n\nDid you mean this?\n    ";
                } else {
                    $message .= "\n\nDid you mean one of these?\n    ";
                }
                $message .= implode("\n    ", $alternatives);
            }
            
            throw new \InvalidArgumentException($message);
        }
        
        if (count($controllers) > 1) {
            $controllerList = $this->controllers;
            $controllers    = array_filter($controllers, function ($nameOrAlias) use ($controllerList, $controllers) {
                $controllerName = $controllerList[$nameOrAlias]->getName();
                
                return $controllerName === $nameOrAlias || !in_array($controllerName, $controllers);
            });
        }
        
        $exact = in_array($name, $controllers, true);
        if (count($controllers) > 1 && !$exact) {
            $suggestions = $this->getAbbreviationSuggestions(array_values($controllers));
            
            throw new \InvalidArgumentException(sprintf('Controller "%s" is ambiguous (%s).', $name, $suggestions));
        }
        
        return $this->getController($exact ? $name : reset($controllers));
	}
403104
protected function addResourceShow( $name, $base, $controller, $options )
	{
		$uri = $this->getResourceUri( $name ) . '/{' . $base . '';

		$action = $this->getResourceAction( $name, $controller, 'show', $options );

		return $this->router->get( $uri, $action );
	}
503195
public function trackItem($id, $name, array $options = [])
	{
		$options['id'] = $id;
		$options['name'] = $name;
		$this->trackEcommerce(self::ECOMMERCE_ITEM, $options);
	}
227010
public function render($name, $params = null, $options = null)
    {
        return $this->get($name, $options)->render($params);
    }
74929
protected function addPutResourceUpdate($name, $base, $controller, $options)
    {
        $uri = $this->getResourceUri($name) .'/{' .$base .'}';

        $action = $this->getResourceAction($name, $controller, 'update', $options);

        return $this->router->put($uri, $action);
    }
1152280
public function addOptions(string $uri, string $handler, string $name = null)
    {
        $this->addRoute("OPTIONS", $uri, $handler, $name);
    }
768364
public function alterTable($name, array $options = [])
    {
        $schema = isset($options['schema']) ? new Schema($options['schema']) : null;

        return (new TableApi($name, $schema, $this->manipulation, $this->actions))
            ->alterTable();
    }
1267070
protected function getOptionsList($name, $options)
    {
        if (empty($options)) {
            $options = $this->getOptionsFromModel($name);
        }

        return $options;
    }
423142
public function options(string $uri, string $controller, string $action)
    {
        $this->addRoute('OPTIONS', $uri, $controller, $action);
    }
853073
protected function runCommand(string $name, $handler, array $options)
    {
        if (\is_object($handler) && \method_exists($handler, '__invoke')) {
            if ($this->input->getSameOpt(['h', 'help'])) {
                $desc = $options['description'] ?? 'No command description message';

                return $this->output->write($desc);
            }

            $result = $handler($this->input, $this->output);
        } else {
            if (!\class_exists($handler)) {
                Helper::throwInvalidArgument("The console command class [$handler] not exists!");
            }

            /** @var Command $object */
            $object = new $handler($this->input, $this->output);

            if (!($object instanceof Command)) {
                Helper::throwInvalidArgument("The console command class [$handler] must instanceof the " . Command::class);
            }

            $object::setName($name);
            $object->setApp($this);
            $result = $object->run();
        }

        return $result;
    }