url() vs route() Possibly a silly questions..
What's the advantage of using route($routeName) over url($route), other than being more organized and looking neater?
The route helper function uses the route name. If you change your URL for some reason in the future, the route helper function will reflect that as long as the name of the route remains the same.
You can also easily pass parameters to the route() helper, making it easy to do URIs like /user/2/edit by doing
route('user.edit', [$user->id])
Can't do that with url()?
more over, you can treat one as end user facing (url) and other as application facing. You can have as absurd (but convenient) as possible name route
route('my.absurd.route')
which then translates to /welcome. but with url you don't get this facility.
OK, so it's pretty much what I figured. Not sure which answer to accept, but thanks everyone!
Please sign in or create an account to participate in this conversation.