0

The situation is quite tricky... For example I have URL http://example.com/users

which shows all users. I also have few filters like

http://example.com/users?sort_type=ASC&sort_value=surname

or

http://example.com/users?sort_type=DESC&sort_value=name.

There also is the search which looks like this

http://example.com/users/search/by_name/?search_value=bob

or http://example.com/users/search/by_surname/?search_value=miller.

For the search I also need to add filtering params, so the main problem is in first symbol: when there is the list of users it should be ?, when search &. So is there some url generation function for generating url from URL params?

1 Answer 1

1

All values not using by route mask will append as query params. (change route name from 'users' to yours)

URL::route('users', array(
  'sort_type' => 'ASC',
  'sort_value' => 'surname'
));

If you don't use routes then use something like this

$query = http_build_query(array(
      'sort_type' => 'ASC',
      'sort_value' => 'surname'
));
URL::to(action('UserController@index') . '?' . $query );
Sign up to request clarification or add additional context in comments.

1 Comment

Note the route has to be named 'users'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.