1
In the Laravel 5, I am creating a menu dynamically, making a foreach  in the list of registered routes.
So I can have a menu displayed each time a new route is created, but I’m only listing the ones that contém the method index in the controller.
Thus:
@foreach(Route::getRoutes() as $route)
 @if(Str::finish($route->getName(), '.index'))
 <li>
   {{ link_to_route($route->getName()) }}
 </li>
 @endif
@endforeach
However, in the second parameter of link_to_route, it would be interesting to pass a title for this route. So I would have the links with the name well descriptive for the route, instead of displaying the url complete.
Is there any way in the creation of Rota, create a title for that route (I’m not talking about the option "as" which is used internally)?
Is there any way to define an attribute in the controller method or in the route for me to use as the Route? I can do that in Laravel?
Very interesting @Wallacemaxters, I think this might simplify something I was doing in my application... how do I display this custom attribute in the view I loaded? Like, when I access the home I pull the title inside a <H1> for example
– Raylan Soares
just put {{ $action['title'] }} ?
– Raylan Soares
@Raylansoares notes that in
ifwho has thearray_keys_existsi create the variable$actionwithin theif. This not to call the method$route->getAction()twice...– Wallace Maxters