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
|
|
|
$customerMenu = $this->buildCustomerMenu(); |
27
|
|
|
|
28
|
|
|
return array_merge($userMenu, $customerMenu); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get the navigation links for Users |
33
|
|
|
*/ |
34
|
|
|
protected function buildUserMenu() |
35
|
|
|
{ |
36
|
|
|
$userBuild = []; |
37
|
|
|
// if($this->checkPermission($this->user, 'Manage Users')) |
38
|
|
|
// { |
39
|
|
|
// $userBuild = [ |
40
|
|
|
// [ |
41
|
|
|
// 'name' => 'Create New User', |
42
|
|
|
// 'icon' => 'fas fa-user-plus', |
43
|
|
|
// 'link' => '#', // route('admin.user.create'), |
44
|
|
|
// ], |
45
|
|
|
// [ |
46
|
|
|
// 'name' => 'Modify User', |
47
|
|
|
// 'icon' => 'fas fa-user-edit', |
48
|
|
|
// 'link' => '#', // route('admin.user.list'), |
49
|
|
|
// ], |
50
|
|
|
// [ |
51
|
|
|
// 'name' => 'Show Deactivated Users', |
52
|
|
|
// 'icon' => 'fas fa-store-alt-slash', |
53
|
|
|
// 'link' => '#', // route('admin.disabled.index'), |
54
|
|
|
// ], |
55
|
|
|
// ]; |
56
|
|
|
// } |
57
|
|
|
|
58
|
|
|
$roleBuild = []; |
59
|
|
|
// if($this->checkPermission($this->user, 'Manage Permissions')) |
60
|
|
|
// { |
61
|
|
|
// $roleBuild = [[ |
62
|
|
|
// 'name' => 'User Roles and Permissions', |
63
|
|
|
// 'icon' => 'fas fa-users-cog', |
64
|
|
|
// 'link' => '#', // route('admin.user-roles.index'), |
65
|
|
|
// ]]; |
66
|
|
|
// } |
67
|
|
|
|
68
|
|
|
return ['Users' => array_merge($userBuild, $roleBuild)]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the navigation links for customers |
74
|
|
|
*/ |
75
|
|
|
protected function buildCustomerMenu() |
76
|
|
|
{ |
77
|
|
|
$nav = []; |
78
|
|
|
|
79
|
|
|
if($this->checkPermission($this->user, 'Manage Customers')) |
80
|
|
|
{ |
81
|
|
|
$nav = [ |
82
|
|
|
'Manage Customers' => [ |
83
|
|
|
[ |
84
|
|
|
'name' => 'Change Customer ID Number', |
85
|
|
|
'icon' => 'fas fa-fingerprint', |
86
|
|
|
'link' => route('admin.cust.change-id.index'), |
87
|
|
|
], |
88
|
|
|
[ |
89
|
|
|
'name' => 'View Deactivated Customers', |
90
|
|
|
'icon' => 'fas fa-ban', |
91
|
|
|
'link' => '#', // route('customers.show-deactivated'), |
92
|
|
|
], |
93
|
|
|
[ |
94
|
|
|
'name' => 'Customer File Types', |
95
|
|
|
'icon' => 'fas fa-file-alt', |
96
|
|
|
'link' => '#' |
97
|
|
|
], |
98
|
|
|
], |
99
|
|
|
]; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return $nav; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|