MuhammadYasser's avatar

route() vs url() vs action() in blade

is using route() instead of url() and action() consider best practice or each of them has its superiority cases?

0 likes
2 replies
pcarvalho1981's avatar

I'm a newbie but I try to use route() instead of the other two, every time I can.

1 like
D9705996's avatar

Route() allows you to use named routes so if you change a route using named routes you only need to change route definition whereas url() calls would all need updated

https://stackoverflow.com/questions/50487047/url-vs-route-in-laravel-5-6

Action gives a url from a controller action.

Have a look at this for more details

https://laravel.com/docs/5.8/helpers#urls

My preference route() but it's just that. Choose one that works for you and usd it consistently

3 likes

Please or to participate in this conversation.