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

Case 1 — single parameter:

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

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

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

@juukie
Copy link
Contributor

juukie commented Dec 9, 2014

What if a route parameter and querystring parameter are named equal and I wanted to change both?

@JosephSilber
Copy link
Contributor

I don't think grabbing the naked $_GET array like that is in the spirit of anything else being done here.

How are you ever gonna test that?

@GrahamCampbell
Copy link
Collaborator

@JosephSilber is correct.

Sorry, but I can't allow this in.

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.

4 participants