문제

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

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.

다른 팁

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)

}));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top