Laravel 8 Get Request Parameters in Controller

Share Me
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares
Laravel 8 Get Request Parameters in Controller

Now today in this blog,I will give you a example of how to get request parameters in Laravel 8 application.If we get query string value then we can get by using Request Facade OR Input Facade in larave 8 application. Here we know how to get Laravel 8 Get Request Parameters in Controller.

In Laravel 8 we can get url in pass parameters if we get parameters value then use bellow example.

Just need to follow in bellow example we can easily get request parameters values.

At First we can create route in web.php file.

routes/web.php

Route::get('contact-us','FrontHomeController@contactUs');

you can create contactUs method in controller file.In this example in use HTTP Request.

Example 1

public function contactUs(Request $request)
{ 
    $allParameters = $request->all();

    dd($allParameters);
}

Output

array:3 [?
  "id" => "2"
  "name" => ""xyz""
  "msg" => ""hiii""
]

Second example in you can use Input method to get parameters value.

Example 2

public function contactUs(Request $request)
{ 
    $allParameters = Input::all();

    dd($allParameters);
}

Output

array:3 [?
  "id" => "2"
  "name" => ""xyz""
  "msg" => ""hiii""
]

In this solution you can use HTTP Request in query to get url parameters.

Example 3

public function contactUs(Request $request)
{ 
    $allParameters = \Request::query();

    dd($allParameters);
}

Output

array:3 [?
  "id" => "2"
  "name" => ""xyz""
  "msg" => ""hiii""
]

Bellow example in perticuler parameters get to $_GET use.

Example 4

public function contactUs(Request $request)
{ 
    $id = $_GET['id'];

    dd($id);
}

Output

"2"

In this Example in HTTP Request in input() used.

Example 5

public function contactUs(Request $request)
{ 
    $allParameters = $request->input();

    dd($allParameters);
}

Output

array:3 [?
  "id" => "2"
  "name" => ""xyz""
  "msg" => ""hiii""
]

Read Also : Add Charts Using Highcharts In Laravel 8

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 →