-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathAddToAdminMenu.php
42 lines (35 loc) · 1.19 KB
/
AddToAdminMenu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Modules\MyBlog\Listeners;
use App\Events\Menu\AdminCreated;
use App\Traits\Permissions;
class AddToAdminMenu
{
use Permissions;
/**
* Handle the event.
*
* @param AdminCreated $event
* @return void
*/
public function handle(AdminCreated $event)
{
$menu = $event->menu;
$attr = ['icon' => ''];
$title = trim(trans('my-blog::general.name'));
if ($this->canAccessMenuItem($title, ['read-my-blog-posts', 'read-my-blog-comments'])) {
$menu->dropdown($title, function ($sub) use ($attr) {
$title = trim(trans_choice('my-blog::general.posts', 2));
if ($this->canAccessMenuItem($title, 'read-my-blog-posts')) {
$sub->route('my-blog.posts.index', $title, [], 10, $attr);
}
$title = trim(trans_choice('my-blog::general.comments', 2));
if ($this->canAccessMenuItem($title, 'read-my-blog-comments')) {
$sub->route('my-blog.comments.index', $title, [], 20, $attr);
}
}, 15, [
'title' => $title,
'icon' => 'edit',
]);
}
}
}