Laravel Request - Laravel

What is the use of Laravel Request ?

Retrieving the Request URI

To retrieve the requested URI, “path” method will be used. The “is” method is used to retrieve the requested URI which matches the particular pattern specified in the argument of the method. User can use the “url” method to get full URL.


Step 1 − Execute the below command to create a new controller calledUriController.

Step 2 – User can see the following output, after successful execution of the URL


Step 3 – Create a controller and add the following code in that file.


Step 4 − Add the following line in the app/Http/route.php file.


Step 5 − Visit the following URL.


Step 6 − Output will be displayed as in the below image.


Retrieving Input

Laravel retrieving input method will retrieve input values for both methods same way, either “get” and “post”. There are two ways we can retrieve the input values.

  • Using the input() method
  • Using the properties of Request instance

Using the input() method

The input() method has only argument, it is the name of the field in form. For example, if the form contains username field then, user can access it by using below

Using the properties of Request instance

User can get the username property directly from the request instance like the input() method

Step 2 − Execute the below command to create a UserRegistrationcontroller.

Step 3 − User can see the below output, after successful execution.


Step 4 − Copy the following code in app/Http/Controllers/UserRegistration.php controller.


Step 5 − Add the following line in app/Http/routes.php file.


Step 6 – User can see the registration form as displayed in the following picture by visiting the following URL. Type the registration details and click Register to see on the second page, for the displayed the user registration details.


Step 7 − Output can be seen as shown in the below images.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Laravel Topics