Skip to content

Commit

Permalink
updated developer menu
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jul 17, 2020
1 parent fc5b7f5 commit d16b9bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.idea
/.history
/.vscode
/.vagrant
/node_modules
/storage/*.key
/vendor
16 changes: 4 additions & 12 deletions en/developer-manual/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Modules\MyBlog\Listeners;

use App\Events\Menu\AdminCreated as Event;

class AddMenu
class AddToAdminMenu
{
/**
* Handle the event.
Expand All @@ -26,25 +26,17 @@ class AddMenu
{
// Add child to existing menu item
$item = $event->menu->whereTitle(trans_choice('general.sales', 2));
$item->url('my-blog/posts', 'Posts', 4, ['icon' => '']);
$item->route('my-blog.posts.index', trans('my-blog::general.posts'), [], 4, ['icon' => '']);

// Add new menu item
$event->menu->add([
'url' => 'my-blog/posts',
'title' => 'Posts',
'route' => 'my-blog.posts.index',
'title' => trans('my-blog::general.posts'),
'icon' => 'fas fa-pen',
'order' => 5,
]);
}
}
```

Then add your listener into the `$listen` array of your `Modules\MyBlog\Providers\Event` service provider:

```php
'App\Events\Menu\AdminCreated' => [
'Modules\MyBlog\Listeners\AddMenu',
],
```

[Menu](https://github.com/akaunting/menu/wiki) documentation can help to understand the system, especially about how to find a menu item, add child ones, and create dropdown menus.

0 comments on commit d16b9bc

Please sign in to comment.