Completed
Push — master ( d02efc...260d8b )
by wen
20:36
created

RoleController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 35
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getList() 0 7 1
A getAll() 0 5 1
A getPermissionList() 0 5 1
A delete() 0 8 2
A save() 0 3 1
1
<?php
2
3
4
namespace Sco\Admin\Http\Controllers\Manager;
5
6
use Sco\Admin\Exceptions\AdminHttpException;
7
use Sco\Admin\Http\Controllers\BaseController;
8
use Sco\Admin\Models\Permission;
9
use Sco\Admin\Models\Role;
10
11
class RoleController extends BaseController
12
{
13
    public function getList()
14
    {
15
        $roles = Role::with(['perms' => function ($query) {
16
            $query->select('id');
17
        }])->paginate();
18
        return response()->json($roles);
19
    }
20
21
    public function getAll()
22
    {
23
        $roles = Role::all();
24
        return response()->json($roles);
25
    }
26
27
    public function getPermissionList()
28
    {
29
        $perms = (new Permission())->getPermRouteList();
30
        return response()->json($perms, 200, [], JSON_FORCE_OBJECT);
31
    }
32
33
    public function delete($id)
34
    {
35
        if ($id == 1) {
36
            throw new AdminHttpException('超级管理员角色不能删除');
37
38
        }
39
40
    }
41
42
    public function save()
43
    {
44
    }
45
}
46