S
S
seredaes2018-05-21 11:31:58
Laravel
seredaes, 2018-05-21 11:31:58

Is there any difference between url()->route("named_route") and route("named_route")?

Hi all.
I have always used url()->route() in links until recently. But they suggested that you can simply route ('route_names')
Tell me, there is no difference how to use it? Or is there still a difference with url()-> or without?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2018-05-21
@seredaes

We look at the source of the route function:

function route($name, $parameters = [], $absolute = true)
{
    return app('url')->route($name, $parameters, $absolute);
}

Conclusion - no difference.

A
Alexey Ukolov, 2018-05-21
@alexey-m-ukolov

There is no difference other than the number of characters - both ultimately use \Illuminate\Routing\UrlGenerator.
PS Set yourself an IDE and you can easily answer such questions yourself - just go to the definition of the functions of interest.

Y
Yan-s, 2018-05-21
@Yan-s

Both ways are aliases https://laravel.com/api/5.6/Illuminate/Routing/Url...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question