@@ 171-195 (lines=25) @@ | ||
168 | * |
|
169 | * @return \Illuminate\Http\Response |
|
170 | */ |
|
171 | public function delMultiGroups(Request $request) |
|
172 | { |
|
173 | $ids = $request->input('ids'); |
|
174 | if (!isset($ids) || !$ids) { |
|
175 | throw new \InvalidArgumentException('the selected groups cannot been empty.', -10201); |
|
176 | } |
|
177 | ||
178 | $deleted_ids = []; |
|
179 | foreach ($ids as $id) |
|
180 | { |
|
181 | $group = Group::find($id); |
|
182 | if ($group) { |
|
183 | if (isset($group->diectory) && $group->directory && $group->diectory != 'self') { |
|
184 | continue; |
|
185 | } |
|
186 | $group->delete(); |
|
187 | Event::fire(new DelGroupEvent($id)); |
|
188 | $deleted_ids[] = $id; |
|
189 | } |
|
190 | } |
|
191 | return response()->json([ 'ecode' => 0, 'data' => [ 'ids' => $deleted_ids ] ]); |
|
192 | } |
|
193 | } |
|
194 |
@@ 359-384 (lines=26) @@ | ||
356 | * |
|
357 | * @return \Illuminate\Http\Response |
|
358 | */ |
|
359 | public function delMultiUsers(Request $request) |
|
360 | { |
|
361 | $ids = $request->input('ids'); |
|
362 | if (!isset($ids) || !$ids) { |
|
363 | throw new \InvalidArgumentException('the selected users cannot been empty.', -10108); |
|
364 | } |
|
365 | ||
366 | $deleted_ids = []; |
|
367 | foreach ($ids as $id) |
|
368 | { |
|
369 | $user = Sentinel::findById($id); |
|
370 | if ($user) { |
|
371 | if (isset($user->directory) && $user->directory && $user->directory != 'self') { |
|
372 | continue; |
|
373 | } |
|
374 | ||
375 | $user->delete(); |
|
376 | Event::fire(new DelUserEvent($id)); |
|
377 | $deleted_ids[] = $id; |
|
378 | } |
|
379 | } |
|
380 | return response()->json([ 'ecode' => 0, 'data' => [ 'ids' => $deleted_ids ] ]); |
|
381 | } |
|
382 | ||
383 | /** |
|
384 | * valid/invalid all selected users. |
|
385 | * |
|
386 | * @return \Illuminate\Http\Response |
|
387 | */ |