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

http://www.yoursite.com/controllerMethod/indexAction/value

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.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status