Skip to content

Commit

Permalink
Merge pull request #5480 from yeminlideveloper/master
Browse files Browse the repository at this point in the history
Adds config-based route prefix to GenerateMenuCommand.php
  • Loading branch information
jxlwqq committed Dec 3, 2021
2 parents ec84a21 + e7f03ac commit cfd0964
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Console/GenerateMenuCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ public function __construct(Router $router)
public function handle()
{
$routes = collect($this->router->getRoutes())->filter(function (Route $route) {
$prefix = config('admin.route.prefix');
$uri = $route->uri();
// built-in, parameterized and no-GET are ignored
return Str::startsWith($uri, 'admin/')
&& !Str::startsWith($uri, 'admin/auth/')
return Str::startsWith($uri, "{$prefix}/")
&& !Str::startsWith($uri, "{$prefix}/auth/")
&& !Str::endsWith($uri, '/create')
&& !Str::contains($uri, '{')
&& in_array('GET', $route->methods())
&& !in_array(substr($route->uri(), strlen('admin/')), config('admin.menu_exclude'));
&& !in_array(substr($route->uri(), strlen("{$prefix}/")), config('admin.menu_exclude'));
})
->map(function (Route $route) {
$uri = substr($route->uri(), strlen('admin/'));
->map(function (Route $route, $prefix) {
$uri = substr($route->uri(), strlen("{$prefix}/"));

return [
'title' => Str::ucfirst(
Expand All @@ -75,9 +76,9 @@ public function handle()
$news = $routes->diffKeys($menus)->map(function ($item, $key) {
return [
'title' => $item,
'uri' => $key,
'uri' => $key,
'order' => 10,
'icon' => 'fa-list',
'icon' => 'fa-list',
];
})->values()->toArray();

Expand Down

0 comments on commit cfd0964

Please sign in to comment.