Skip to content

Commit

Permalink
navigation wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 27, 2023
1 parent ffa449c commit 787fc6c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Navigation/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Navigation/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, []);
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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)],
);
}

Expand Down

0 comments on commit 787fc6c

Please sign in to comment.