php - Laravel 5.1: Retrieve method(s) for route name? -


is there way method(s) route responds name? urlgenerator (as expect name in fairness), provides url given route name. there service provider can return both url , methods route can respond to? prefer not have hook directly app's route collection if possible.

i think best way go extend urlgenerator. add new method return array of http methods allowed route.

public function getmethodsforroute($name) {     if (! is_null($route = $this->routes->getbyname($name)))     {         return $route->methods();     }      throw new invalidargumentexception("route [{$name}] not defined."); } 

as alternative may able current route router , return them way. less elegant, however. (note untested)

$name = 'route.name';  $router = app('illuminate\routing\router');  if (! is_null($route = $router->getroutes()->getbyname($name))) {     $methods = $route->methods(); } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -