Sending parameters to a controller

Keyboard Shortcuts

Back in the day, parameters were sent to applications with GET parameters with the question mark (?). Nowadays, parameters can be more intuitive and readable. Routes may receive parameters, and you may also pass these parameters to the next layer on your controller. From there, you may pass these parameters to the model and finally to the view. In this video, learn how to send and receive parameters within your routes.

- [Instructor] So now that we have directed our route…to certain controller methods,…we want to send parameters to these routes,…which should be sent through the url.…In the past we would use GET parameters…by using the question mark to denote variables.…However, in the context of Frameworks,…we can now pass parameters separated by the slash symbol.…So for example, to get the details of a client,…whose ID is four,…we could use the url client slash four.…

This style is more intuitive…and helps make urls more readable.…The way to go is…to surround our parameters with curly braces.…So let's create a new route for client details…and add our client ID.…Go to web dot php…and let's copy line 17 and paste it.…We'll change to get…and we're going to add a new parameter with curly braces.…

Client underscore ID and the method…is going to change to show.…Now let's create our method show in the client's controller…with public function, show.…Now let's add the parameter as client underscore ID.…While we're not obliged…to name the parameter client underscore ID,…

Resume Transcript Auto-Scroll

Author

Released

8/24/2017

Frameworks allow you to do more with less code. Laravel is the most popular MVC framework for PHP. This course covers the basics you need to know to build elegant applications of any scale with Laravel. Learn how to work with the MVC architecture, bootstrap components with service providers, and incorporate the ORM Eloquent for simplified database integration. Instructor Bernard Pineda also covers dependency injection, routing to controllers, views, Blade templates, form creation, and form validation. These tutorials provide the information you need to make a move to Laravel and build high-quality, scalable, and sound PHP applications.