Total Complexity | 6 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class RoleRepository |
||
15 | { |
||
16 | use Searchable; |
||
17 | |||
18 | public static function list($perPage, $condition = []) |
||
19 | { |
||
20 | $data = Role::query() |
||
21 | ->where(function ($query) use ($condition) { |
||
22 | Searchable::buildQuery($query, $condition); |
||
23 | }) |
||
24 | ->orderBy('id', 'desc') |
||
25 | ->paginate($perPage); |
||
26 | $data->transform(function ($item) { |
||
27 | xssFilter($item); |
||
28 | $item->editUrl = route('admin::role.edit', ['id' => $item->id]); |
||
29 | $item->permissionUrl = route('admin::role.permission.edit', ['id' => $item->id]); |
||
30 | return $item; |
||
31 | }); |
||
32 | |||
33 | return [ |
||
34 | 'code' => 0, |
||
35 | 'msg' => '', |
||
36 | 'count' => $data->total(), |
||
37 | 'data' => $data->items(), |
||
38 | ]; |
||
39 | } |
||
40 | |||
41 | public static function add($data) |
||
42 | { |
||
43 | return Role::query()->create($data); |
||
44 | } |
||
45 | |||
46 | public static function update($id, $data) |
||
47 | { |
||
48 | return Role::query()->where('id', $id)->update($data); |
||
49 | } |
||
50 | |||
51 | public static function find($id) |
||
52 | { |
||
53 | return Role::query()->find($id); |
||
54 | } |
||
55 | |||
56 | public static function all() |
||
59 | } |
||
60 | |||
61 | public static function exist($name) |
||
62 | { |
||
64 | } |
||
65 | } |
||
66 |