1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Helpers; |
4
|
|
|
|
5
|
|
|
class NavbarItemHelper extends MenuItemHelper |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Check if a menu item is a navbar custom search bar. |
9
|
|
|
* |
10
|
|
|
* @param mixed $item |
11
|
|
|
* @return bool |
12
|
|
|
*/ |
13
|
51 |
|
public static function isCustomSearch($item) |
14
|
|
|
{ |
15
|
51 |
|
return isset($item['text'], $item['type']) && |
16
|
51 |
|
$item['type'] === 'navbar-search'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Check if a menu item is a navbar fullscreen toggle widget. |
21
|
|
|
* |
22
|
|
|
* @param mixed $item |
23
|
|
|
* @return bool |
24
|
|
|
*/ |
25
|
3 |
|
public static function isFullscreen($item) |
26
|
|
|
{ |
27
|
3 |
|
return isset($item['type']) && |
28
|
3 |
|
$item['type'] === 'fullscreen-widget'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Check if a menu item is a navbar dark mode toggle widget. |
33
|
|
|
* |
34
|
|
|
* @param mixed $item |
35
|
|
|
* @return bool |
36
|
|
|
*/ |
37
|
3 |
|
public static function isDarkmode($item) |
38
|
|
|
{ |
39
|
3 |
|
return isset($item['type']) && |
40
|
3 |
|
$item['type'] === 'darkmode-widget'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Check if a menu item is a navbar notification. |
45
|
|
|
* |
46
|
|
|
* @param mixed $item |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
3 |
|
public static function isNotification($item) |
50
|
|
|
{ |
51
|
3 |
|
return isset($item['id'], $item['icon'], $item['type']) && |
52
|
3 |
|
(isset($item['url']) || isset($item['route'])) && |
53
|
3 |
|
$item['type'] === 'navbar-notification'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Check if a menu item is a navbar search item (legacy or new). |
58
|
|
|
* |
59
|
|
|
* @param mixed $item |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
53 |
|
public static function isSearch($item) |
63
|
|
|
{ |
64
|
53 |
|
return self::isLegacySearch($item) || |
65
|
53 |
|
self::isCustomSearch($item); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Check if a menu item is accepted for the navbar section. |
70
|
|
|
* |
71
|
|
|
* @param mixed $item |
72
|
|
|
* @return bool |
73
|
|
|
*/ |
74
|
3 |
|
public static function isAcceptedItem($item) |
75
|
|
|
{ |
76
|
3 |
|
return self::isNotification($item) || |
77
|
3 |
|
self::isFullscreen($item) || |
78
|
3 |
|
self::isDarkmode($item) || |
79
|
3 |
|
self::isSubmenu($item) || |
80
|
3 |
|
self::isSearch($item) || |
81
|
3 |
|
self::isLink($item); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Check if a menu item is valid for the left section of the navbar. |
86
|
|
|
* |
87
|
|
|
* @param mixed $item |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
1 |
|
public static function isValidLeftItem($item) |
91
|
|
|
{ |
92
|
1 |
|
return self::isAcceptedItem($item) && |
93
|
1 |
|
isset($item['topnav']) && |
94
|
1 |
|
$item['topnav']; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Check if a menu item belongs to the right section of the navbar. |
99
|
|
|
* |
100
|
|
|
* @param mixed $item |
101
|
|
|
* @return bool |
102
|
|
|
*/ |
103
|
1 |
|
public static function isValidRightItem($item) |
104
|
|
|
{ |
105
|
1 |
|
return self::isAcceptedItem($item) && |
106
|
1 |
|
isset($item['topnav_right']) && |
107
|
1 |
|
$item['topnav_right']; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Check if a menu item belongs to the user menu section of the navbar. |
112
|
|
|
* |
113
|
|
|
* @param mixed $item |
114
|
|
|
* @return bool |
115
|
|
|
*/ |
116
|
1 |
|
public static function isValidUserMenuItem($item) |
117
|
|
|
{ |
118
|
1 |
|
return self::isAcceptedItem($item) && |
119
|
1 |
|
isset($item['topnav_user']) && |
120
|
1 |
|
$item['topnav_user']; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|