Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Exploring Resource Routes In Laravel

Laravel comes with lots of time-saving gems out-of-the-box, resourceful Routes is one of them.

In this article, we will explore the resource routes, how to define one, and what we get in return.

What is a resource route?

A resource route is a shortcut route that can be defined in a routes file. The resource style route will state that there will be data related to the route and therefore, we need the generic CRUD (create, read, update, and delete) routes. This can be also known as a RESTful route.

Once defined, there will be seven routes immediately configured within the application routing system.

How to define a resource route

Now for some magic syntax, in the applications routes file, for example, specifically in the routes/web.php file, add the following syntax.

Route::resource('employee', 'EmployeeController');

And that is it, all seven routes are magically stacked behind this syntax. We can check this by running the following php artisan route:list command.

This is the output of the route list –

And that is a resourceful route in a nutshell. If you’re interested in creating a CRUD style application, you can follow my tutorial on creating a CRUD app with resource controllers here.

The post Exploring Resource Routes In Laravel appeared first on Code Wall.



This post first appeared on Code Wall - Web Development & Programming, please read the originial post: here

Share the post

Exploring Resource Routes In Laravel

×

Subscribe to Code Wall - Web Development & Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×