diff --git a/README.md b/README.md index 24f7b79..e5efb83 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,27 @@ $panel->plugins([ php artisan vendor:publish --tag=api-service-config ``` +```php + +return [ + 'navigation' => [ + 'token' => [ + 'group' => 'User', + 'sort' => -1, + 'icon' => 'heroicon-o-key' + ] + ], + 'models' => [ + 'token' => [ + 'enable_policy' => true, + ], + ], + 'route' => [ + 'wrap_with_panel_id' => true, + ], +]; +``` + ## Usage ```bash diff --git a/config/api-service.php b/config/api-service.php index 6fc8d2e..87d4b72 100644 --- a/config/api-service.php +++ b/config/api-service.php @@ -1,15 +1,25 @@ [ + /** + * @deprecated 3.2 + */ 'group' => [ 'token' => 'User', ], + 'token' => [ + 'group' => 'User', + 'sort' => -1, + 'icon' => 'heroicon-o-key', + ], ], 'models' => [ 'token' => [ 'enable_policy' => true, ], ], + 'route' => [ + 'wrap_with_panel_id' => true, + ], ]; diff --git a/routes/api.php b/routes/api.php index 12b117c..b74b83b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -10,14 +10,17 @@ foreach ($panels as $key => $panel) { try { - - Route::prefix($panel->getId()) - ->name($panel->getId() . '.') - ->group(function () use ($panel) { - $apiServicePlugin = $panel->getPlugin('api-service'); - $apiServicePlugin->route($panel); - }); - + if (config('api-service.route.wrap_with_panel_id', true)) { + Route::prefix($panel->getId()) + ->name($panel->getId() . '.') + ->group(function () use ($panel) { + $panel->getPlugin('api-service') + ->route($panel); + }); + } else { + $panel->getPlugin('api-service') + ->route($panel); + } } catch (Exception $e) { } } diff --git a/src/Resources/TokenResource.php b/src/Resources/TokenResource.php index 9c59b61..2b19142 100644 --- a/src/Resources/TokenResource.php +++ b/src/Resources/TokenResource.php @@ -23,7 +23,7 @@ class TokenResource extends Resource { protected static ?string $model = Token::class; - protected static ?string $navigationIcon = 'heroicon-o-key'; + // protected static ?string $navigationIcon = 'heroicon-o-key'; public static function form(Form $form): Form { @@ -130,6 +130,16 @@ public static function getPages(): array public static function getNavigationGroup(): ?string { - return config('api-service.navigation.group.token'); + return config('api-service.navigation.token.group') ?? config('api-service.navigation.group.token'); + } + + public static function getNavigationSort(): ?int + { + return config('api-service.navigation.token.sort', -1); + } + + public static function getNavigationIcon(): ?string + { + return config('api-service.navigation.token.icon', 'heroicon-o-key'); } }