@@ 40-64 (lines=25) @@ | ||
37 | } |
|
38 | ||
39 | //[Function] roleIndex |
|
40 | public function roleIndex(Request $request){ |
|
41 | ||
42 | $response = array(); |
|
43 | ||
44 | if (request()->has('sort')) { |
|
45 | list($sortCol, $sortDir) = explode('|', request()->sort); |
|
46 | ||
47 | $query = $this->role->orderBy($sortCol, $sortDir); |
|
48 | } else { |
|
49 | $query = $this->role->orderBy('id', 'asc'); |
|
50 | } |
|
51 | ||
52 | if ($request->exists('filter')) { |
|
53 | $query->where(function($q) use($request) { |
|
54 | $value = "%{$request->filter}%"; |
|
55 | $q->where('name', 'like', $value) |
|
56 | ->orWhere('description', 'like', $value); |
|
57 | }); |
|
58 | } |
|
59 | ||
60 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
|
61 | $response = $query->paginate($perPage); |
|
62 | ||
63 | return response()->json($response); |
|
64 | } |
|
65 | ||
66 | //[Function] roleStore |
|
67 | public function roleStore(Request $request){ |
|
@@ 163-186 (lines=24) @@ | ||
160 | } |
|
161 | ||
162 | //[Function] permissionIndex |
|
163 | public function permissionIndex(Request $request){ |
|
164 | $response = array(); |
|
165 | ||
166 | if (request()->has('sort')) { |
|
167 | list($sortCol, $sortDir) = explode('|', request()->sort); |
|
168 | ||
169 | $query = $this->permission->orderBy($sortCol, $sortDir); |
|
170 | } else { |
|
171 | $query = $this->permission->orderBy('id', 'asc'); |
|
172 | } |
|
173 | ||
174 | if ($request->exists('filter')) { |
|
175 | $query->where(function($q) use($request) { |
|
176 | $value = "%{$request->filter}%"; |
|
177 | $q->where('name', 'like', $value) |
|
178 | ->orWhere('description', 'like', $value); |
|
179 | }); |
|
180 | } |
|
181 | ||
182 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
|
183 | $response = $query->paginate($perPage); |
|
184 | ||
185 | return response()->json($response); |
|
186 | } |
|
187 | ||
188 | //[Function] permissionStore |
|
189 | public function permissionStore(Request $request){ |