0

How can I get ? queries from url? input::all not works.

my route :

Route::get('category/(:any?)','category@index');

what I wanted to get is like :

http://url.com/category/examplecategory?list_as=grid&price_range=2

prinr_r of Input::all(). why can't I have list_as => grid and price_range => 2

Array ( [category/examplecategory] => )

my output should be :

Array ( [list_as] => "grid" , [price_range] => 2 [another_filter] => "another value"....)

2 Answers 2

1

Could you provide more feedback as to what you require, and your desired output.

Will your GET data be parsed against a query to return a dataset?

To produce a URL http://url.com/category/examplecategory/grid/2

Example:

Route::get('category/{examplecategory}/{listas}/{pricerange}', array(function($tripCode) {

    $data = Model::FUNCTION_QUERY($examplecategory,$listas,$pricerange); // these are the values passed in the SEO friendly URL 

    return View::make('categoryview/')->with("data", $data)

}));

This essentially uses the URL above, passes the data to a model which returns a dataset in $data, this then is passed into a view called categoryview with all the data which is then processed. I hope this helps a little?

If you want to use posts data try this:

Route::get('category/{examplecategory}', array(function($tripCode) {
    $postsdata = Input::all();

    $data = Model::FUNCTION_QUERY($examplecategory,$postdata); // these are the values passed in the SEO friendly URL 

    return View::make('categoryview/')->with("data", $data)

}));
Sign up to request clarification or add additional context in comments.

2 Comments

Can't I just use my route as is and get queries starts with ? because its not limited just with listas and pricerange. There are tons of filters.
Yes you can, You can use the $data = Input::all();
0

You may try this

parse_str(Request::getQueryString(), $getVars);

// Use these as
echo $getVars['list_as'];
echo $getVars['price_range'];

Here, Request::getQueryString() (it's method of symfony Request class) will return a query string and parse_str will build the array and will put it into $getVars.

Comments

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.