Reputation: 510
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"....)
Upvotes: 0
Views: 394
Reputation: 146191
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
.
Upvotes: 0
Reputation: 344
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)
}));
Upvotes: 1