Completed
Push — master ( c53116...d0984d )
by Jeremy
07:52
created

LaravelRolesController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 21
rs 9.7333
c 0
b 0
f 0
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;
0 ignored issues
show
introduced by
The trait jeremykenedy\LaravelRoles\Traits\RolesGUITraits requires some properties which are not provided by jeremykenedy\LaravelRole...\LaravelRolesController: $id, $permission_id, $role_id, $roles
Loading history...
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));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('laravelrole...board', compact($data)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
63
    }
64
65
}
66