diff --git a/src/Navigation/Item.php b/src/Navigation/Item.php index 76e68d8a..993a8a86 100644 --- a/src/Navigation/Item.php +++ b/src/Navigation/Item.php @@ -20,7 +20,6 @@ public function __construct(string $url, string $label, array $attributes = []) $this->url($url); $this->label($label); $this->icon('archive'); - $this->group(__('General')); $this->setAttributes($attributes); } diff --git a/src/Navigation/Location.php b/src/Navigation/Location.php index d6477803..38dacf57 100644 --- a/src/Navigation/Location.php +++ b/src/Navigation/Location.php @@ -25,7 +25,7 @@ public function __construct(string $name) public function groups(): array { return array_reduce($this->items, static function (array $groups, Item $item): array { - $groups[$item->group][] = $item; + $groups[$item->group ?? __('General')][] = $item; return $groups; }, []); diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index 37fcbf29..613329eb 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -63,6 +63,11 @@ abstract class Resource implements Arrayable, Form */ protected string $icon = 'archive'; + /** + * The group for the resource. + */ + protected string $group = 'General'; + /** * Boot the resource. */ @@ -75,7 +80,7 @@ public function boot(Root $root): void $root->navigation->location('sidebar')->new( $this->getUri(), $this->getName(), - ['icon' => $this->getIcon()] + ['icon' => $this->getIcon(), 'group' => __($this->group)], ); }