Home » Laravel

Route in Laravel

Laravel Route: In this tutorial, we are going to discuss how to work with Laravel: Here, we will see How to create route in Laravel?
Submitted by Bharti Parmar, on November 18, 2019

For further process we need to know something about it,

The route is a core part in Laravel because it maps the controller for sending a request which is automatically loaded by the Laravel framework.

Route in Laravel

Now, here we create a new route named "post" for postcontroller.php from which PostController.php can handle all the process.

Path: "routes/web.php"

Laravel | Route
  • Here, get is the method like PHP "get" and "post" methods.
  • The route has two parameters "URL" and "closure" function, which is an anonymous function that is used as a parameter to another function.
  • In the Route::resource('posts','PostController');
  • Here, posts in place of URL because it is mandatory to pass the parameter in place of URL. It is used to open and show the static pages made by us in resources/views directory and controlling by the controller's file like PostController.php.
  • Here, we are using "resources" in place of "get", because our view page is in the resource directory which is controlled by PostController.php.

Conclusion:

In this article, we have learnt about the routes in Laravel. I hope you understood the concept, will know more about it in the upcoming articles. Have a great day! Happy Learning!



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.