1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jeremykenedy\LaravelRoles\App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use Illuminate\Http\Response; |
7
|
|
|
use jeremykenedy\LaravelRoles\Traits\RolesGUITraits; |
8
|
|
|
|
9
|
|
|
class LaravelRolesController extends Controller |
10
|
|
|
{ |
11
|
|
|
use RolesGUITraits; |
|
|
|
|
12
|
|
|
|
13
|
|
|
private $_rolesGuiAuthEnabled; |
14
|
|
|
private $_rolesGuiMiddlewareEnabled; |
15
|
|
|
private $_rolesGuiMiddleware; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Create a new controller instance. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function __construct() |
23
|
|
|
{ |
24
|
|
|
$this->_rolesGuiAuthEnabled = config('roles.rolesGuiAuthEnabled'); |
25
|
|
|
$this->_rolesGuiMiddlewareEnabled = config('roles.rolesGuiMiddlewareEnabled'); |
26
|
|
|
$this->_rolesGuiMiddleware = config('roles.rolesGuiMiddleware'); |
27
|
|
|
|
28
|
|
|
if ($this->_rolesGuiAuthEnabled) { |
29
|
|
|
$this->middleware('auth'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if ($this->_rolesGuiMiddlewareEnabled) { |
33
|
|
|
$this->middleware($this->_rolesGuiMiddleware); |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Show the roles and Permissions dashboard. |
39
|
|
|
* |
40
|
|
|
* @return \Illuminate\Http\Response |
41
|
|
|
*/ |
42
|
|
|
public function index() |
43
|
|
|
{ |
44
|
|
|
$roles = $this->getRoles(); |
45
|
|
|
$permissions = $this->getPermissions(); |
46
|
|
|
$deletedRoleItems = $this->getDeletedRoles(); |
47
|
|
|
$users = $this->getUsers(); |
48
|
|
|
$sortedRolesWithUsers = $this->getSortedUsersWithRoles($roles, $users); |
49
|
|
|
$sortedRolesWithPermissionsAndUsers = $this->getSortedRolesWithPermissionsAndUsers($sortedRolesWithUsers, $permissions); |
50
|
|
|
$sortedPermissionsRolesUsers = $this->getSortedPermissonsWithRolesAndUsers($sortedRolesWithUsers, $permissions); |
51
|
|
|
|
52
|
|
|
$data = [ |
53
|
|
|
'roles', |
54
|
|
|
'permissions', |
55
|
|
|
'deletedRoleItems', |
56
|
|
|
'users', |
57
|
|
|
'sortedRolesWithUsers', |
58
|
|
|
'sortedRolesWithPermissionsAndUsers', |
59
|
|
|
'sortedPermissionsRolesUsers', |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
return view('laravelroles::laravelroles.crud.dashboard', compact($data)); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|