Tuesday, 15 June 2010

php - Laravel get route name from given URL -


In Laravel, we can get the root name from the current URL via:

 < Code> root:: CurrentRouteName ()  

But how can we get the root name from a given given URL?

Thank you.

Laravel 5.2

Code> App ('router') - & gt; GetRoutes () - & gt; Match (app ('request') -> Create ('/ qqq / post / 68 / u1')) - & gt; GetName ()

This is my root name like slug.posts.show

You can do this for , Delete or Delete or Delete Code> app ('router') - & gt; GetRoutes () - & gt; Match (app ('request') -> Create ('/ qqq / posts / 68 / u1', 'POST')) - & gt; GetName () // Reference https: //github.com/symfony/http-foundation/blob/master/Request.php#L309

In addition to the app (' ('(Qqq / posts / 68 / u1', 'POST')) - Illuminate this lighting \ root + example where you can access many useful public methods like getAction , getValidators etc. For more information, check the source.


No comments:

Post a Comment