Code Duplication    Length = 16-16 lines in 2 locations

src/Http/Api/GroupController.php 1 location

@@ 161-176 (lines=16) @@
158
     * @param  int  $id
159
     * @return \Illuminate\Http\Response
160
     */
161
    public function destroy($id)
162
    {
163
        $group = Group::find($id);
164
        if (!$group)
165
        {
166
            throw new \UnexpectedValueException('the group does not exist.', -10201);
167
        }
168
        if (isset($group->diectory) && $group->directory && $group->diectory != 'self')
169
        {
170
            throw new \UnexpectedValueException('the group come from external directroy.', -10203);
171
        }
172
173
        Group::destroy($id);
174
        Event::fire(new DelGroupEvent($id));
175
        return Response()->json([ 'ecode' => 0, 'data' => [ 'id' => $id ] ]);
176
    }
177
178
    /**
179
     * delete all selected groups.

src/Http/Api/UserController.php 1 location

@@ 368-383 (lines=16) @@
365
     * @param  int  $id
366
     * @return \Illuminate\Http\Response
367
     */
368
    public function destroy($id)
369
    {
370
        $user = Sentinel::findById($id);
371
        if (!$user)
372
        {
373
            throw new \UnexpectedValueException('the user does not exist.', -10106);
374
        }
375
        if (isset($user->diectory) && $user->directory && $user->diectory != 'self')
376
        {
377
            throw new \UnexpectedValueException('the user come from external directroy.', -10109);
378
        }
379
380
        $user->delete();
381
        Event::fire(new DelUserEvent($id));
382
        return Response()->json([ 'ecode' => 0, 'data' => [ 'id' => $id ] ]);
383
    }
384
385
    /**
386
     * delete all selected users.