Skip to content

Conversation

@litvinchuk
Copy link
Contributor

This method basically conveniently changes parameters of the current url.

Example URL:

Route::get('/{lang}/users/profile/{id}/article/{slug}', function($lang, $id, $slug) {
 // ...
});

# http://laravel/en/users/profile/12/article/super-awesome-article?page=12

Case 1 — single parameter:

URL::alter(['lang' => 'uk'])
# http://laravel/uk/users/profile/12/article/super-awesome-article?page=12

Case 2 — multiple parameters:

URL::alter(['lang' => 'uk', 'slug' => 'best-of-the-best-of-the-best'])
# http://laravel/uk/users/profile/12/article/best-of-the-best-of-the-best?page=12

Case 3 — multiple parameters with GET params:

URL::alter(
  ['lang' => 'uk', 'slug' => 'best-of-the-best-of-the-best'],
  ['page' => 7, 'order' => 'desc']
)
# http://laravel/uk/users/profile/12/article/best-of-the-best-of-the-best?page=7&order=desc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't align these please.

@GrahamCampbell GrahamCampbell changed the title [5.0] Extending UrlGenerator with url alter method [5.0] Extending UrlGenerator With Url Alter Method Dec 13, 2014
@taylorotwell
Copy link
Member

Hmm, going to hold off on including this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants