public function urlFor($name, $params = array())
    {
        if (!$this->hasNamedRoute($name)) {
            throw new \RuntimeException('Named route not found for name: ' . $name);
        }
        $search = array();
        foreach ($params as $key => $value) {
            $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#';
        }
        $pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern());

        //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters
        return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern);
    }
public function urlFor($name, $params = array())
    {
        if (!$this->hasNamedRoute($name)) {
            throw new \RuntimeException('Named route not found for name: ' . $name);
        }
        $search = array();
        foreach ($params as $key => $value) {
            $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#';
        }
        $pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern());

        //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters
        return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern);
    }
public function urlFor ( $ name , $ params = array ( ) ) { if ( ! $ this -> hasNamedRoute ( $ name ) ) { throw new \ RuntimeException ( 'Named route not found for name: ' . $ name ) ; } $ search = array ( ) ; foreach ( $ params as $ key => $ value ) { $ search [ ] = '#:' . preg_quote ( $ key , '#' ) . '\+?(?!\w)#' ; } $ pattern = preg_replace ( $ search , $ params , $ this -> getNamedRoute ( $ name ) -> getPattern ( ) ) ; //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters return preg_replace ( '#\(/?:.+\)|\(|\)|\\\\#' , '' , $ pattern ) ; }
Get URL for named route
@param  string            $name   The name of the route
@param  array             $params Associative array of URL parameter names and replacement values
@return string                    The URL for the given route populated with provided replacement values
@throws \RuntimeException         If named route not found
@api
Get URL for named route