Code Duplication    Length = 5-5 lines in 2 locations

app/Http/Controllers/Api/v1/ApiController.php 2 locations

@@ 1086-1090 (lines=5) @@
1083
                return response()->json(compact('error'));
1084
            }
1085
            $id = $this->request->input('user_id');
1086
            if ($this->user->where('id', $id)->first()->role == 'user') {
1087
                $error = 'This user is not an Agent or Admin';
1088
1089
                return response()->json(compact('error'));
1090
            }
1091
            //$user = \JWTAuth::parseToken()->authenticate();
1092
            $result = $this->user->join('tickets', function ($join) use ($id) {
1093
                $join->on('users.id', '=', 'tickets.assigned_to')
@@ 1197-1201 (lines=5) @@
1194
                return response()->json(compact('error'));
1195
            }
1196
            $id = $this->request->input('id');
1197
            if (!$this->model->where('id', $id)->first()) {
1198
                $error = 'There is no Ticket as ticket id: '.$id;
1199
1200
                return response()->json(compact('error'));
1201
            }
1202
            $query = $this->user->join('tickets', function ($join) use ($id) {
1203
                $join->on('users.id', '=', 'tickets.user_id')
1204
                        ->where('tickets.id', '=', $id);