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

@GrahamCampbell
Copy link
Collaborator

You've labeled as 5.0, but sent this to 4.2?

@GrahamCampbell GrahamCampbell changed the title [5.0] Extending UrlGenerator with url alter method [4.2] Extending UrlGenerator with url alter method Dec 9, 2014
@litvinchuk
Copy link
Contributor Author

sorry, I missed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please put 3 spaces after this particular typehint so it aligns with the others.

Also, please squash to one commit when you're done.

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

Moved to #6613.

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.

2 participants