Skip to content

Commit

Permalink
Merge pull request #26 from rupadana/dev
Browse files Browse the repository at this point in the history
feat: add navigation sort & icon
  • Loading branch information
rupadana authored Mar 6, 2024
2 parents 7665120 + 95081f9 commit 7b38617
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion config/api-service.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<?php

// config for Rupadana/ApiService
return [
'navigation' => [
/**
* @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,
],
];
19 changes: 11 additions & 8 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/Resources/TokenResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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');
}
}

0 comments on commit 7b38617

Please sign in to comment.