laravel - get parameters from http request
In Laravel, you can use the $request
object to access parameters from an HTTP request.
You can access query string parameters using the query
method:
$value = $request->query('key');
You can access route parameters using the route
method:
$value = $request->route('key');
Watch a video course
Learn object oriented PHP
You can access request data (from the request body) using the input
method:
$value = $request->input('key');
You can access all input data, including query string and route parameters, using the all
method:
$data = $request->all();
There is also $request->only()
and $request->except()
to get the field with specific fields and exclude the specific fields.