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 | * @author Alireza Josheghani <[email protected]> |
||
52 | * @since 20 Sep 2016 |
||
53 | * @param $route |
||
54 | * @param $callback |
||
55 | */ |
||
56 | public function sub($route, $callback) |
||
61 | |||
62 | /** |
||
63 | * Attach sub menu array with checking status of item |
||
64 | * @author Alireza Josheghani <[email protected]> |
||
65 | * @since 20 Sep 2016 |
||
66 | * @param $route |
||
67 | * @param $callback |
||
68 | */ |
||
69 | public function subWithCheckStatus($route, $callback) |
||
77 | |||
78 | /** |
||
79 | * Set the icon option |
||
80 | * @author Alireza Josheghani <[email protected]> |
||
81 | * @since 20 Sep 2016 |
||
82 | * @param $icon |
||
83 | */ |
||
84 | public function icon($icon) |
||
89 | |||
90 | /** |
||
91 | * Set the icon tag option |
||
92 | * @author Alireza Josheghani <[email protected]> |
||
93 | * @since 20 Sep 2016 |
||
94 | * @param $icon |
||
95 | */ |
||
96 | public function tag($tag) |
||
101 | |||
102 | /** |
||
103 | * Set the title option |
||
104 | * @author Alireza Josheghani <[email protected]> |
||
105 | * @since 20 Sep 2016 |
||
106 | * @param $title |
||
107 | */ |
||
108 | public function title($title) |
||
112 | |||
113 | /** |
||
114 | * Set the class-name option |
||
115 | * @author Alireza Josheghani <[email protected]> |
||
116 | * @since 20 Sep 2016 |
||
117 | * @param $class_name |
||
118 | */ |
||
119 | public function className($className) |
||
120 | { |
||
121 | $this->class = $className; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Set the newTab option |
||
126 | * @author Alireza Josheghani <[email protected]> |
||
127 | * @since 20 Sep 2016 |
||
128 | * @param $newtab : boolean |
||
129 | */ |
||
130 | public function newTab($newtab) |
||
134 | |||
135 | /** |
||
136 | * Set route name |
||
137 | * @author Alireza Josheghani <[email protected]> |
||
138 | * @since 20 Sep 2016 |
||
139 | * @param $route |
||
140 | */ |
||
141 | public function routeName($route) |
||
145 | |||
146 | /** |
||
147 | * Set the link of menu |
||
148 | * @author Alireza Josheghani <[email protected]> |
||
149 | * @since 20 Sep 2016 |
||
150 | * @param $link |
||
151 | * @return $this |
||
152 | */ |
||
153 | public function link($link) |
||
158 | |||
159 | /** |
||
160 | * Set target link of item |
||
161 | * @author Alireza Josheghani <[email protected]> |
||
162 | * @since 20 Sep 2016 |
||
163 | * @param $isNew |
||
164 | */ |
||
165 | public function isNew($isNew) |
||
166 | { |
||
167 | $this->isNew = $isNew; |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Set item is selected |
||
172 | * @author Alireza Josheghani <[email protected]> |
||
173 | * @since 20 Sep 2016 |
||
174 | * @param $type |
||
175 | */ |
||
176 | public function selected($type) |
||
180 | |||
181 | /** |
||
182 | * Set open child when item is active |
||
183 | * @author Alireza Josheghani <[email protected]> |
||
184 | * @since 20 Sep 2016 |
||
185 | * @param $type |
||
186 | */ |
||
187 | public function openChildOnClick($type) |
||
191 | |||
192 | /** |
||
193 | * make the return item array |
||
194 | * @author Alireza Josheghani <[email protected]> |
||
195 | * @since 20 Sep 2016 |
||
196 | * @return array |
||
197 | */ |
||
198 | public function make($route) |
||
226 | |||
227 | } |
||
228 |