From ec6e03da575e4083a034e5acb18d579c83a2894f Mon Sep 17 00:00:00 2001 From: Sergiy Litvinchuk Date: Wed, 10 Dec 2014 01:10:46 +0200 Subject: [PATCH] [5.0] Extending UrlGenerator With Url Alter Method --- src/Illuminate/Routing/UrlGenerator.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Illuminate/Routing/UrlGenerator.php b/src/Illuminate/Routing/UrlGenerator.php index 595bb6124fcb..a6b827858123 100755 --- a/src/Illuminate/Routing/UrlGenerator.php +++ b/src/Illuminate/Routing/UrlGenerator.php @@ -94,6 +94,23 @@ public function current() return $this->to($this->request->getPathInfo()); } + /** + * Get the current URL with one or more replaced parameters + * + * @param array $routeParameters + * @param array $getParameters + * @param bool $absolute + * @return string + */ + public function alter(array $routeParameters = array(), array $getParameters = array(), $absolute = true) + { + $replacedRouteParameters = $routeParameters + $this->request->route()->parameters(); + $replacedGetParameters = $getParameters + $this->request->query->all(); + + return $this->toRoute($this->request->route(), $replacedRouteParameters, $absolute) + . $this->getRouteQueryString($replacedGetParameters); + } + /** * Get the URL for the previous request. *