1 | <?php |
||
38 | class Permission extends EntrustPermission |
||
39 | { |
||
40 | use TreeTrait; |
||
41 | |||
42 | protected $guarded = ['created_at', 'updated_at']; |
||
43 | |||
44 | protected $treeNodeParentIdName = 'pid'; |
||
45 | |||
46 | private $allRoutes = null; |
||
47 | |||
48 | private $permList = null; |
||
49 | |||
50 | private $menuList = null; |
||
51 | |||
52 | protected $fillable = ['pid', 'display_name', 'name', 'icon', 'is_menu', 'sort', 'description']; |
||
53 | |||
54 | protected $events = [ |
||
55 | 'created' => \Sco\ActionLog\Events\ModelWasCreated::class, |
||
56 | 'updated' => \Sco\ActionLog\Events\ModelWasUpdated::class, |
||
57 | 'deleted' => \Sco\ActionLog\Events\ModelWasDeleted::class, |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * @return \Illuminate\Support\Collection |
||
62 | */ |
||
63 | public function getMenuTreeList() |
||
64 | { |
||
65 | $routes = $this->getDescendants(0); |
||
66 | //dd($routes); |
||
67 | return $routes; |
||
68 | } |
||
69 | |||
70 | private function getAll() |
||
71 | { |
||
72 | if ($this->allRoutes) { |
||
73 | return $this->allRoutes; |
||
74 | } |
||
75 | |||
76 | $this->allRoutes = Cache::rememberForever( |
||
77 | 'permission_all', |
||
78 | function () { |
||
79 | return $this->orderBy('sort')->get(); |
||
|
|||
80 | } |
||
81 | ); |
||
82 | return $this->allRoutes; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Tree Trait 获取所有节点 |
||
87 | * |
||
88 | * @return mixed|null |
||
89 | */ |
||
90 | protected function getTreeAllNodes() |
||
94 | |||
95 | /** |
||
96 | * 获取权限列表 |
||
97 | * |
||
98 | * @return \Illuminate\Support\Collection|null |
||
99 | */ |
||
100 | public function getPermRouteList() |
||
108 | |||
109 | public function getMenuList() |
||
126 | |||
127 | /** |
||
128 | * 删除菜单 |
||
129 | * |
||
130 | * @param int|array $ids 菜单ID |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function destroyMenu($ids) |
||
155 | |||
156 | public static function boot() |
||
162 | } |
||
163 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: