How to Get Query Strings Value in Laravel?

By Hardik Savani October 8, 2020 Category : Laravel

If you want to get Query string value then you can get using Request Facade OR Input Facade in larave 5. But if you was working native PHP then we can get $_GET method.

we can get query string parameters in laravel 6, laravel 7, laravel 8 and laravel 9 application.

Let's see bellow examples

In following example you can easily get parameter value.

URL Example:

http://text.com/wall?id=23&name=hdtopi

In above query string, you want to get query string value for example id and name. you can get through bellow example.

Route Example:

Route::get('wall', 'WallController@wall');

Controller Example:

public function wall(Request $request)

{

/* returns Ony Id value */

$id = $request->input('id');


/* returns array of entire input query value */

$query = $request->all();


/* OR */


/* returns Ony Id value */

$id = Input::get('id');


/* returns array of entire input query value */

$query = Input::all();

}

We are Recommending you