| @@ 6-43 (lines=38) @@ | ||
| 3 | use Illuminate\Routing\Route; |
|
| 4 | use Illuminate\Foundation\Console\RouteListCommand; |
|
| 5 | ||
| 6 | class CheckRoutePermission extends RouteListCommand |
|
| 7 | { |
|
| 8 | ||
| 9 | /** |
|
| 10 | * {@inheritdoc} |
|
| 11 | */ |
|
| 12 | protected $name = 'permission:route:permission'; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * {@inheritdoc} |
|
| 16 | */ |
|
| 17 | protected $description = 'Table of all routes that do not have a permission'; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * {@inheritdoc} |
|
| 21 | */ |
|
| 22 | protected $headers = ['method', 'uri', 'name', 'controller', 'action', 'middleware']; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | protected function getRouteInformation(Route $route) |
|
| 28 | { |
|
| 29 | $actions = explode('@',$route->getActionName()); |
|
| 30 | $middleware = implode(',',$route->middleware()); |
|
| 31 | ||
| 32 | if(!strpos($middleware, 'permission')) { |
|
| 33 | return $this->filterRoute([ |
|
| 34 | 'method' => implode('|', $route->methods()), |
|
| 35 | 'uri' => $route->uri(), |
|
| 36 | 'name' => is_string($route->getName()) ? "<fg=green>{$route->getName()}</>" : "-", |
|
| 37 | 'controller' => isset($actions[0]) ? "<fg=cyan>{$actions[0]}</>" : "-", |
|
| 38 | 'action' => isset($actions[1]) ? "<fg=red>{$actions[1]}</>" : "-", |
|
| 39 | 'middleware' => $middleware |
|
| 40 | ]); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 6-43 (lines=38) @@ | ||
| 3 | use Illuminate\Routing\Route; |
|
| 4 | use Illuminate\Foundation\Console\RouteListCommand; |
|
| 5 | ||
| 6 | class CheckRouteRole extends RouteListCommand |
|
| 7 | { |
|
| 8 | ||
| 9 | /** |
|
| 10 | * {@inheritdoc} |
|
| 11 | */ |
|
| 12 | protected $name = 'permission:route:role'; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * {@inheritdoc} |
|
| 16 | */ |
|
| 17 | protected $description = 'Table of all routes that do not have a role'; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * {@inheritdoc} |
|
| 21 | */ |
|
| 22 | protected $headers = ['method', 'uri', 'name', 'controller', 'action', 'middleware']; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | protected function getRouteInformation(Route $route) |
|
| 28 | { |
|
| 29 | $actions = explode('@',$route->getActionName()); |
|
| 30 | $middleware = implode(',',$route->middleware()); |
|
| 31 | ||
| 32 | if(!strpos($middleware, 'role')) { |
|
| 33 | return $this->filterRoute([ |
|
| 34 | 'method' => implode('|', $route->methods()), |
|
| 35 | 'uri' => $route->uri(), |
|
| 36 | 'name' => is_string($route->getName()) ? "<fg=green>{$route->getName()}</>" : "-", |
|
| 37 | 'controller' => isset($actions[0]) ? "<fg=cyan>{$actions[0]}</>" : "-", |
|
| 38 | 'action' => isset($actions[1]) ? "<fg=red>{$actions[1]}</>" : "-", |
|
| 39 | 'middleware' => $middleware |
|
| 40 | ]); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||