Code Duplication    Length = 28-32 lines in 2 locations

app/Http/Controllers/Agent/helpdesk/TicketController.php 1 location

@@ 2096-2127 (lines=32) @@
2093
     *
2094
     * @return type Redirect
2095
     */
2096
    public function ratingReply($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
2097
    {
2098
        foreach ($request->all() as $key => $value) {
2099
            $key1 = explode(',', $key);
2100
            if (strpos($key1[0], '_') !== false) {
2101
                $ratName = str_replace('_', ' ', $key1[0]);
2102
            } else {
2103
                $ratName = $key1[0];
2104
            }
2105
2106
            $ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
2107
            $ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('thread_id', '=', $key1[1])->first();
2108
2109
            if ($ratingrefs !== null) {
2110
                $ratingrefs->rating_id = $ratID->id;
2111
                $ratingrefs->ticket_id = $id;
2112
2113
                $ratingrefs->thread_id = $key1[1];
2114
                $ratingrefs->rating_value = $value;
2115
                $ratingrefs->save();
2116
            } else {
2117
                $rating_ref->rating_id = $ratID->id;
2118
                $rating_ref->ticket_id = $id;
2119
2120
                $rating_ref->thread_id = $key1[1];
2121
                $rating_ref->rating_value = $value;
2122
                $rating_ref->save();
2123
            }
2124
        }
2125
2126
        return redirect()->back()->with('Success', 'Thank you for your rating!');
2127
    }
2128
2129
    /**
2130
     * System default email.

app/Http/Controllers/Client/helpdesk/UnAuthController.php 1 location

@@ 204-231 (lines=28) @@
201
     *
202
     * @return type Redirect
203
     */
204
    public function ratingReply($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
205
    {
206
        foreach ($request->all() as $key => $value) {
207
            $key1 = explode(',', $key);
208
            if (strpos($key1[0], '_') !== false) {
209
                $ratName = str_replace('_', ' ', $key1[0]);
210
            } else {
211
                $ratName = $key1[0];
212
            }
213
            $ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
214
            $ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('thread_id', '=', $key1[1])->first();
215
            if ($ratingrefs !== null) {
216
                $ratingrefs->rating_id = $ratID->id;
217
                $ratingrefs->ticket_id = $id;
218
                $ratingrefs->thread_id = $key1[1];
219
                $ratingrefs->rating_value = $value;
220
                $ratingrefs->save();
221
            } else {
222
                $rating_ref->rating_id = $ratID->id;
223
                $rating_ref->ticket_id = $id;
224
                $rating_ref->thread_id = $key1[1];
225
                $rating_ref->rating_value = $value;
226
                $rating_ref->save();
227
            }
228
        }
229
230
        return redirect()->back()->with('Success', Lang::get('lang.thank_you_for_your_rating'));
231
    }
232
233
    /**
234
     * function to change the status of the ticket.