1 | <?php |
||
13 | class Menu |
||
14 | { |
||
15 | |||
16 | // the route name |
||
17 | protected $route; |
||
18 | |||
19 | // the title option |
||
20 | protected $title; |
||
21 | |||
22 | // the url option |
||
23 | protected $link = [ |
||
24 | 'new_tab' => false, |
||
25 | 'value' => null |
||
26 | ]; |
||
27 | |||
28 | // the class-name option |
||
29 | protected $class; |
||
30 | |||
31 | // the icon option |
||
32 | protected $icon = [ |
||
33 | 'tag' => 'i', |
||
34 | 'value' => null |
||
35 | ]; |
||
36 | |||
37 | // is_new icon option : boolean |
||
38 | protected $isNew = false; |
||
39 | |||
40 | // selected option |
||
41 | protected $selected = false; |
||
42 | |||
43 | // open child when item is active : boolean |
||
44 | protected $openChildOnClick = true; |
||
45 | |||
46 | // the sub menu array |
||
47 | protected $submenu = []; |
||
48 | |||
49 | /** |
||
50 | * Attach sub menu array |
||
51 | * |
||
52 | * @author Alireza Josheghani <[email protected]> |
||
53 | * @since 20 Sep 2016 |
||
54 | * @param $route |
||
55 | * @param $callback |
||
56 | */ |
||
57 | public function sub($route, $callback) |
||
62 | |||
63 | /** |
||
64 | * Attach sub menu array with checking status of item |
||
65 | * |
||
66 | * @author Alireza Josheghani <[email protected]> |
||
67 | * @since 20 Sep 2016 |
||
68 | * @param $route |
||
69 | * @param $callback |
||
70 | */ |
||
71 | public function subWithCheck($route, $callback) |
||
72 | { |
||
73 | if(SideNav::checkStatus($route) === true) { |
||
74 | $sub = SideNav::addSub($route, $callback); |
||
75 | array_push($this->submenu, $sub); |
||
76 | } |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Set the icon option |
||
81 | * |
||
82 | * @author Alireza Josheghani <[email protected]> |
||
83 | * @since 20 Sep 2016 |
||
84 | * @param $icon |
||
85 | */ |
||
86 | public function icon($icon) |
||
91 | |||
92 | /** |
||
93 | * Set the icon tag option |
||
94 | * |
||
95 | * @author Alireza Josheghani <[email protected]> |
||
96 | * @since 20 Sep 2016 |
||
97 | * @param $icon |
||
98 | */ |
||
99 | public function tag($tag) |
||
104 | |||
105 | /** |
||
106 | * Set the title option |
||
107 | * |
||
108 | * @author Alireza Josheghani <[email protected]> |
||
109 | * @since 20 Sep 2016 |
||
110 | * @param $title |
||
111 | */ |
||
112 | public function title($title) |
||
116 | |||
117 | /** |
||
118 | * Set the class-name option |
||
119 | * |
||
120 | * @author Alireza Josheghani <[email protected]> |
||
121 | * @since 20 Sep 2016 |
||
122 | * @param $class_name |
||
123 | */ |
||
124 | public function className($className) |
||
128 | |||
129 | /** |
||
130 | * Set the newTab option |
||
131 | * |
||
132 | * @author Alireza Josheghani <[email protected]> |
||
133 | * @since 20 Sep 2016 |
||
134 | * @param $newtab : boolean |
||
135 | */ |
||
136 | public function newTab($newtab) |
||
140 | |||
141 | /** |
||
142 | * Set route name |
||
143 | * |
||
144 | * @author Alireza Josheghani <[email protected]> |
||
145 | * @since 20 Sep 2016 |
||
146 | * @param $route |
||
147 | */ |
||
148 | public function routeName($route) |
||
152 | |||
153 | /** |
||
154 | * Set the link of menu |
||
155 | * |
||
156 | * @author Alireza Josheghani <[email protected]> |
||
157 | * @since 20 Sep 2016 |
||
158 | * @param $link |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function link($link) |
||
166 | |||
167 | /** |
||
168 | * Set target link of item |
||
169 | * |
||
170 | * @author Alireza Josheghani <[email protected]> |
||
171 | * @since 20 Sep 2016 |
||
172 | * @param $isNew |
||
173 | */ |
||
174 | public function isNew($isNew) |
||
178 | |||
179 | /** |
||
180 | * Set item is selected |
||
181 | * |
||
182 | * @author Alireza Josheghani <[email protected]> |
||
183 | * @since 20 Sep 2016 |
||
184 | * @param $type |
||
185 | */ |
||
186 | public function selected($type) |
||
190 | |||
191 | /** |
||
192 | * Set open child when item is active |
||
193 | * |
||
194 | * @author Alireza Josheghani <[email protected]> |
||
195 | * @since 20 Sep 2016 |
||
196 | * @param $type |
||
197 | */ |
||
198 | public function openChildOnClick($type) |
||
202 | |||
203 | /** |
||
204 | * make the return item array |
||
205 | * |
||
206 | * @author Alireza Josheghani <[email protected]> |
||
207 | * @since 20 Sep 2016 |
||
208 | * @return array |
||
209 | */ |
||
210 | public function make($route) |
||
240 | |||
241 | } |
||
242 |