Code Duplication    Length = 16-16 lines in 2 locations

src/Http/Controllers/MessagesController.php 2 locations

@@ 242-257 (lines=16) @@
239
     *
240
     * @param $id
241
     */
242
    public function read(Request $request)
243
    {
244
        if (! $request->ajax()) {
245
            abort(404);
246
        }
247
248
        if ($threadIds = $request->threads) {
249
            $threads = $this->threads->whereIn('id', $threadIds)->get();
250
            foreach ($threads as $thread) {
251
                $thread->markAsRead(auth()->id());
252
            }
253
            $collection = new Fractal\Resource\Collection($threads, new ThreadTransformer);
254
255
            return $this->fractal->createData($collection)->toArray();
256
        }
257
    }
258
259
    /**
260
     * Mark a specific thread as unread, for ajax use.
@@ 264-279 (lines=16) @@
261
     *
262
     * @param $id
263
     */
264
    public function unread(Request $request)
265
    {
266
        if (! $request->ajax()) {
267
            abort(404);
268
        }
269
270
        if ($threadIds = $request->threads) {
271
            $threads = $this->threads->whereIn('id', $threadIds)->get();
272
            foreach ($threads as $thread) {
273
                $thread->markAsUnread(auth()->id());
274
            }
275
            $collection = new Fractal\Resource\Collection($threads, new ThreadTransformer);
276
277
            return $this->fractal->createData($collection)->toArray();
278
        }
279
    }
280
281
    /**
282
     * Delete a thread, for ajax use.