Laravel 6 Get Request Parameters in Controller
Dec 03, 2019
Hii guys,
In this blog,I will teach you how to get request parameters in Laravel 6.If you get query string value then you can get using Request Facade OR Input Facade in larave 6.
Laravel 6 in You can url in pass parameters if you get parameters value then use bellow example.
In bellow example you can easily get request parameters values.
First you 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""
]
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial