1 | <?php |
||
35 | class Menu extends Node |
||
36 | { |
||
37 | use PresentableTrait, PublishableTrait, CanRequireAuthentication; |
||
38 | use AuditableTrait, HasParameters, HasOrder, SortableTrait; |
||
39 | |||
40 | public $sortable = [ |
||
41 | 'order_column_name' => 'order', |
||
42 | 'sort_when_creating' => true, |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $touches = ['navigation']; |
||
49 | |||
50 | /** |
||
51 | * @var \Yajra\CMS\Presenters\MenuPresenter |
||
52 | */ |
||
53 | protected $presenter = MenuPresenter::class; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $fillable = [ |
||
59 | 'title', |
||
60 | 'url', |
||
61 | 'target', |
||
62 | 'order', |
||
63 | 'published', |
||
64 | 'parent_id', |
||
65 | 'authenticated', |
||
66 | 'authorization', |
||
67 | 'parameters', |
||
68 | 'extension_id', |
||
69 | ]; |
||
70 | |||
71 | /** |
||
72 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
73 | */ |
||
74 | public function navigation() |
||
78 | |||
79 | /** |
||
80 | * Related menu permissions. |
||
81 | * |
||
82 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
83 | */ |
||
84 | public function permissions() |
||
88 | |||
89 | /** |
||
90 | * Get related article. |
||
91 | * |
||
92 | * @return \Yajra\CMS\Entities\Article |
||
93 | */ |
||
94 | public function article() |
||
98 | |||
99 | /** |
||
100 | * Get related category. |
||
101 | * |
||
102 | * @return \Yajra\CMS\Entities\Article |
||
103 | */ |
||
104 | public function category() |
||
111 | |||
112 | /** |
||
113 | * Menu type relation. |
||
114 | * |
||
115 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
116 | */ |
||
117 | public function menuType() |
||
121 | |||
122 | /** |
||
123 | * Get list of possible parent node. |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | public function getParentsList() |
||
147 | |||
148 | /** |
||
149 | * @param \Baum\Node $node |
||
150 | * @param array $items |
||
151 | * @return array |
||
152 | */ |
||
153 | protected function appendMenu($node, &$items) |
||
168 | |||
169 | /** |
||
170 | * Check if the menu has the given widget. |
||
171 | * |
||
172 | * @param mixed $widget |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function hasWidget($widget) |
||
183 | |||
184 | /** |
||
185 | * Get related widgets. |
||
186 | * |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function widgets() |
||
193 | |||
194 | /** |
||
195 | * Check if the menu is currently selected/active. |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | public function isActive() |
||
200 | { |
||
201 | $url = url($this->present()->url()); |
||
202 | $path = request()->path(); |
||
203 | |||
204 | return $url == request()->url() || $url == $path || url($url, [], true) == url($path, [], true); |
||
|
|||
205 | } |
||
206 | |||
207 | /** |
||
208 | * Get related extension. |
||
209 | * |
||
210 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
211 | */ |
||
212 | public function extension() |
||
216 | } |
||
217 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.