From the beginning, even in a small project, I highly suggest naming routes. I will cover a few examples of how and why here.
A base install of Laravel is great. I will use some routes and views from above but you can easily follow along.
Follow the listed steps for creating named routes:
To begin with, let's look at some routes I have:
> php artisan route:list
You will see something like this if you followed along so far, else you will just see the default Laravel route.
Notice the
name
section; that is what we are aiming for here.Note the
admin
sectionadmin.memberships
andadmin.users
in myapp/routes.php
file:See the
->name()
method at the end of theRoute
facade, it is the cause of this magic.Also notice the dot notation naming to help organize a bit more. This is optional but I like it for grouping like routes.
Here is where it comes in handy though, open up the test and swap out the path for the route method:
See the following route...