Last active
May 27, 2017 19:25
-
-
Save xtrasmal/d4f2d1857e221a5ce9d69f1f038b5860 to your computer and use it in GitHub Desktop.
Laravel Route table command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Console\Commands; | |
use Illuminate\Routing\Route; | |
use Illuminate\Foundation\Console\RouteListCommand; | |
class RouteTable extends RouteListCommand | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $name = 'route:table'; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $description = 'Table of all registered routes'; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $headers = ['method', 'uri', 'name', 'controller', 'action']; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function getRouteInformation(Route $route) | |
{ | |
$actions = explode('@',$route->getActionName()); | |
return $this->filterRoute([ | |
'method' => implode('|', $route->methods()), | |
'uri' => $route->uri(), | |
'name' => is_string($route->getName()) ? "<fg=green>{$route->getName()}</>" : "-", | |
'controller' => isset($actions[0]) ? "<fg=cyan>{$actions[0]}</>" : "-", | |
'action' => isset($actions[1]) ? "<fg=red>{$actions[1]}</>" : "-" | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment