Skip to content

Apply fixes from StyleCI #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/Controllers/RouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ class RouteController extends Controller
public function index()
{
return Admin::content(function (Content $content) {

$model = $this->getModel()->setRoutes($this->getRoutes());

$content->body(Admin::grid($model, function (Grid $grid) {

$colors = [
'GET' => 'green',
'HEAD' => 'gray',
'POST' => 'blue',
'PUT' => 'yellow',
'DELETE' => 'red',
'PATCH' => 'aqua',
'OPTIONS'=> 'light-blue'
'OPTIONS'=> 'light-blue',
];

$grid->method()->map(function ($method) use ($colors) {
return "<span class=\"label bg-{$colors[$method]}\">$method</span>";
})->implode("&nbsp;");
})->implode('&nbsp;');

$grid->uri()->display(function ($uri) {
return preg_replace('/\{.+?\}/', '<code>$0</span>', $uri);
Expand Down Expand Up @@ -63,8 +61,7 @@ public function index()

protected function getModel()
{
return new class extends Model {

return new class() extends Model {
protected $routes;

protected $where = [];
Expand All @@ -91,15 +88,13 @@ public function orderBy()
public function get()
{
$this->routes = collect($this->routes)->filter(function ($route) {

foreach ($this->where as $column => $condition) {
if (!Str::contains($route[$column], $condition)) {
return false;
}
}

return true;

})->all();

$instance = $this->newModelInstance();
Expand Down Expand Up @@ -129,7 +124,8 @@ public function getRoutes()
/**
* Get the route information for a given route.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Routing\Route $route
*
* @return array
*/
protected function getRouteInformation(Route $route)
Expand All @@ -147,8 +143,9 @@ protected function getRouteInformation(Route $route)
/**
* Sort the routes by a given element.
*
* @param string $sort
* @param array $routes
* @param string $sort
* @param array $routes
*
* @return array
*/
protected function sortRoutes($sort, $routes)
Expand All @@ -161,7 +158,8 @@ protected function sortRoutes($sort, $routes)
/**
* Get before filters.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Routing\Route $route
*
* @return string
*/
protected function getRouteMiddleware($route)
Expand All @@ -170,4 +168,4 @@ protected function getRouteMiddleware($route)
return $middleware instanceof \Closure ? 'Closure' : $middleware;
});
}
}
}
6 changes: 2 additions & 4 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Encore\Admin\Admin;
use Encore\Admin\Auth\Database\Menu;
use Encore\Admin\Extension;
use Illuminate\Support\Facades\Route;

class Helpers extends Extension
{
Expand Down Expand Up @@ -74,11 +73,10 @@ public static function import()
'title' => 'Routes',
'icon' => 'fa-list-alt',
'uri' => 'helpers/routes',
]
],
];

foreach ($menus as $menu) {

$menu['parent_id'] = $root->id;
$menu['order'] = $lastOrder++;

Expand All @@ -87,4 +85,4 @@ public static function import()

parent::createPermission('Admin helpers', 'ext.helpers', 'helpers/*');
}
}
}
2 changes: 1 addition & 1 deletion src/HelpersServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public function boot()

Helpers::boot();
}
}
}