Code Duplication    Length = 16-16 lines in 2 locations

src/Http/Api/GroupController.php 1 location

@@ 151-166 (lines=16) @@
148
     * @param  int $id
149
     * @return \Illuminate\Http\Response
150
     */
151
    public function destroy($id)
152
    {
153
        $group = Group::find($id);
154
        if (!$group) {
155
            throw new \UnexpectedValueException('the group does not exist.', -10201);
156
        }
157
        if (isset($group->diectory) && $group->directory && $group->diectory != 'self') {
158
            throw new \UnexpectedValueException('the group come from external directroy.', -10203);
159
        }
160
161
        Group::destroy($id);
162
        Event::fire(new DelGroupEvent($id));
163
        return response()->json([ 'ecode' => 0, 'data' => [ 'id' => $id ] ]);
164
    }
165
166
    /**
167
     * delete all selected groups.
168
     *
169
     * @return \Illuminate\Http\Response

src/Http/Api/UserController.php 1 location

@@ 339-354 (lines=16) @@
336
     * @param  int $id
337
     * @return \Illuminate\Http\Response
338
     */
339
    public function destroy($id)
340
    {
341
        $user = Sentinel::findById($id);
342
        if (!$user) {
343
            throw new \UnexpectedValueException('the user does not exist.', -10106);
344
        }
345
        if (isset($user->diectory) && $user->directory && $user->diectory != 'self') {
346
            throw new \UnexpectedValueException('the user come from external directroy.', -10109);
347
        }
348
349
        $user->delete();
350
        Event::fire(new DelUserEvent($id));
351
        return response()->json([ 'ecode' => 0, 'data' => [ 'id' => $id ] ]);
352
    }
353
354
    /**
355
     * delete all selected users.
356
     *
357
     * @return \Illuminate\Http\Response