laravel 5 controller get url parameters

The Request facade will grant you access to the current request that is bound in the container.Remember, if you are in a namespace, you will have to import the Request facade using a use Request; statement at the top of your class file.

You can access parameters several ways, let me show you some of the methods,

Method 1 :

If you have your parameter attached to the URL without question mark like

Your route for this controller will look something like this
get('controllerMethod/indexAction/{key}','[email protected]');

You can get the value of this parameter in your controller function by passing the same name of variable in your controller method as you used in the route.

Method 2 :

You can access all the request data with Request facade, below is the snippet.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments Protection Status
Would love your thoughts, please comment.x