How To Get Query String Value From Url In Laravel 5

In this tutorial, we will learn how to get query string value from URL using Request Facade in blade view and controller in Laravel 5 and Laravel 6.

URL Example

Getting query string value in the controller

To get Query string value in the controller. we can get using Request facade

public function dummy(Request $request)
    // returns only type
    $type = request('type'); // or
    $type = $request->type; // or
    $type = $request->input('type'); // or
    $type = $request->query('type');

    dd($type); // latest

You can use any one method to retrieve the query string value. You will get the same result.

Getting query string value in the view (blade)

To get the query string value in view. we can use the helper method.

For Example

{{ request()->query('type') }}