1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Actions; |
4
|
|
|
|
5
|
|
|
use App\Models\User; |
6
|
|
|
use App\Traits\AllowTrait; |
7
|
|
|
|
8
|
|
|
class BuildAdminMenu |
9
|
|
|
{ |
10
|
|
|
use AllowTrait; |
11
|
|
|
|
12
|
|
|
protected $user; |
13
|
|
|
|
14
|
|
|
public function __construct(User $user) |
15
|
|
|
{ |
16
|
|
|
$this->user = $user; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get the Admin links that the user has permission to access |
21
|
|
|
*/ |
22
|
|
|
public function execute() |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
$userMenu = $this->buildUserMenu(); |
26
|
|
|
$equipMenu = $this->buildEquipmentMenu(); |
27
|
|
|
$customerMenu = $this->buildCustomerMenu(); |
28
|
|
|
$techTipMenu = $this->buildTechTipMenu(); |
29
|
|
|
$settingsMenu = $this->buildSettingsMenu(); |
30
|
|
|
$maintMenu = $this->buildMaintenanceMenu(); |
31
|
|
|
|
32
|
|
|
return array_merge($userMenu, $equipMenu, $customerMenu, $techTipMenu, $settingsMenu, $maintMenu); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get the navigation links for Users |
37
|
|
|
*/ |
38
|
|
|
protected function buildUserMenu() |
39
|
|
|
{ |
40
|
|
|
$userBuild = []; |
41
|
|
|
if($this->checkPermission($this->user, 'Manage Users')) |
42
|
|
|
{ |
43
|
|
|
$userBuild = [ |
44
|
|
|
[ |
45
|
|
|
'name' => 'Create New User', |
46
|
|
|
'icon' => 'fas fa-user-plus', |
47
|
|
|
'link' => route('admin.user.create'), |
48
|
|
|
], |
49
|
|
|
[ |
50
|
|
|
'name' => 'Modify User', |
51
|
|
|
'icon' => 'fas fa-user-edit', |
52
|
|
|
'link' => route('admin.user.index'), |
53
|
|
|
], |
54
|
|
|
[ |
55
|
|
|
'name' => 'Show Deactivated Users', |
56
|
|
|
'icon' => 'fas fa-store-alt-slash', |
57
|
|
|
'link' => route('admin.deactivated-users'), |
58
|
|
|
], |
59
|
|
|
[ |
60
|
|
|
'name' => 'Password Policy', |
61
|
|
|
'icon' => 'fas fa-user-lock', |
62
|
|
|
'link' => route('admin.password-policy'), |
63
|
|
|
], |
64
|
|
|
]; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$roleBuild = []; |
68
|
|
|
if($this->checkPermission($this->user, 'Manage Permissions')) |
69
|
|
|
{ |
70
|
|
|
$roleBuild = [[ |
71
|
|
|
'name' => 'User Roles and Permissions', |
72
|
|
|
'icon' => 'fas fa-users-cog', |
73
|
|
|
'link' => route('admin.user-roles.index'), |
74
|
|
|
]]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return ['Users' => array_merge($userBuild, $roleBuild)]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Get the navigation links for Equipment and Equipment Categories |
82
|
|
|
*/ |
83
|
|
|
protected function buildEquipmentMenu() |
84
|
|
|
{ |
85
|
|
|
$nav = []; |
86
|
|
|
|
87
|
|
|
if($this->checkPermission($this->user, 'Manage Equipment')) |
88
|
|
|
{ |
89
|
|
|
$nav = [ |
90
|
|
|
'Manage Equipment' => [ |
91
|
|
|
[ |
92
|
|
|
'name' => 'Equipment Categories', |
93
|
|
|
'icon' => '', |
94
|
|
|
'link' => '#', |
95
|
|
|
], |
96
|
|
|
[ |
97
|
|
|
'name' => 'Equipment Types', |
98
|
|
|
'icon' => '', |
99
|
|
|
'link' => '#', |
100
|
|
|
], |
101
|
|
|
[ |
102
|
|
|
'name' => 'Equipment Data Types (for customers)', |
103
|
|
|
'icon' => '', |
104
|
|
|
'link' => '#', |
105
|
|
|
], |
106
|
|
|
], |
107
|
|
|
]; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $nav; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get the navigation links for customers |
115
|
|
|
*/ |
116
|
|
|
protected function buildCustomerMenu() |
117
|
|
|
{ |
118
|
|
|
$nav = []; |
119
|
|
|
|
120
|
|
|
if($this->checkPermission($this->user, 'Manage Customers')) |
121
|
|
|
{ |
122
|
|
|
$nav = [ |
123
|
|
|
'Manage Customers' => [ |
124
|
|
|
[ |
125
|
|
|
'name' => 'Change Customer ID Number', |
126
|
|
|
'icon' => 'fas fa-fingerprint', |
127
|
|
|
'link' => route('admin.cust.change-id.index'), |
128
|
|
|
], |
129
|
|
|
[ |
130
|
|
|
'name' => 'View Deactivated Customers', |
131
|
|
|
'icon' => 'fas fa-ban', |
132
|
|
|
'link' => route('admin.cust.show-deactivated'), |
133
|
|
|
], |
134
|
|
|
[ |
135
|
|
|
'name' => 'Customer Uploaded File Types', |
136
|
|
|
'icon' => 'fas fa-file-alt', |
137
|
|
|
'link' => route('admin.cust.file-types.index'), |
138
|
|
|
], |
139
|
|
|
], |
140
|
|
|
]; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
return $nav; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Build Navigation menu for Tech Tips |
148
|
|
|
*/ |
149
|
|
|
protected function buildTechTipMenu() |
150
|
|
|
{ |
151
|
|
|
$nav = []; |
152
|
|
|
|
153
|
|
|
if($this->checkPermission($this->user, 'Manage Tech Tips')) |
154
|
|
|
{ |
155
|
|
|
$nav = [ |
156
|
|
|
'Manage Tech Tips' => [ |
157
|
|
|
[ |
158
|
|
|
'name' => 'Tech Tip Types', |
159
|
|
|
'icon' => 'fas fa-file-alt', |
160
|
|
|
'link' => route('admin.tips.tip-types.index'), |
161
|
|
|
], |
162
|
|
|
[ |
163
|
|
|
'name' => 'View Deleted Tech Tips', |
164
|
|
|
'icon' => 'fas fa-ban', |
165
|
|
|
'link' => route('admin.tips.deleted'), |
166
|
|
|
], |
167
|
|
|
[ |
168
|
|
|
'name' => 'View Flagged Comments', |
169
|
|
|
'icon' => 'far fa-flag', |
170
|
|
|
'link' => route('tips.comments.index'), |
171
|
|
|
], |
172
|
|
|
], |
173
|
|
|
]; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
return $nav; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Build navigation menu for Application Settings |
181
|
|
|
*/ |
182
|
|
|
protected function buildSettingsMenu() |
183
|
|
|
{ |
184
|
|
|
$nav = []; |
185
|
|
|
|
186
|
|
|
if($this->checkPermission($this->user, 'App Settings')) |
187
|
|
|
{ |
188
|
|
|
$nav = [ |
189
|
|
|
'Manage Application Settings' => [ |
190
|
|
|
[ |
191
|
|
|
'name' => 'Application Logo', |
192
|
|
|
'icon' => '', |
193
|
|
|
'link' => '#', |
194
|
|
|
], |
195
|
|
|
[ |
196
|
|
|
'name' => 'Application Configuration', |
197
|
|
|
'icon' => '', |
198
|
|
|
'link' => '#', |
199
|
|
|
], |
200
|
|
|
[ |
201
|
|
|
'name' => 'Email Settings', |
202
|
|
|
'icon' => '', |
203
|
|
|
'link' => '#', |
204
|
|
|
], |
205
|
|
|
], |
206
|
|
|
]; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
return $nav; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Build navigation menu for Application Maintenance |
214
|
|
|
*/ |
215
|
|
|
protected function buildMaintenanceMenu() |
216
|
|
|
{ |
217
|
|
|
$nav = []; |
218
|
|
|
|
219
|
|
|
if($this->checkPermission($this->user, 'App Settings')) |
220
|
|
|
{ |
221
|
|
|
$nav = [ |
222
|
|
|
'Application Maintenance' => [ |
223
|
|
|
[ |
224
|
|
|
'name' => 'Application Logs', |
225
|
|
|
'icon' => '', |
226
|
|
|
'link' => '#', |
227
|
|
|
], |
228
|
|
|
[ |
229
|
|
|
'name' => 'Application Backups', |
230
|
|
|
'icon' => '', |
231
|
|
|
'link' => '#', |
232
|
|
|
], |
233
|
|
|
[ |
234
|
|
|
'name' => 'Application Updates', |
235
|
|
|
'icon' => '', |
236
|
|
|
'link' => '#', |
237
|
|
|
], |
238
|
|
|
], |
239
|
|
|
]; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
return $nav; |
243
|
|
|
} |
244
|
|
|
} |
245
|
|
|
|