How to Get Query Strings Value in Laravel?

Today now in this post i will show you how to get query strings value in laravel. If we want to get the Query string value then we can get this by using Request Facade OR also can get by using Input Facade in laravel application. But if we were working with native PHP then we can get this by using $_GET method.

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

So let’s see the bellow examples

Now In the following example we can do this easily get parameter value.

URL Example:

Now in the above query string, we want to get the query string value for an example id and also name. we can get this through the 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();

Read Also: How to git force pull from remote branch ?

Thanks for read. I hope it help you. For more you can follow us onĀ facebook.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →