Code Duplication    Length = 9-11 lines in 3 locations

src/Notifynder/Notifications/NotificationRepository.php 3 locations

@@ 295-304 (lines=10) @@
292
     * @param Closure $filterScope
293
     * @return mixed
294
     */
295
    public function countNotRead($to_id, $entity, Closure $filterScope = null)
296
    {
297
        $query = $this->notification->wherePolymorphic($to_id, $entity)
298
            ->withNotRead()
299
            ->select($this->db->raw('Count(*) as notRead'));
300
301
        $query = $this->applyFilter($filterScope, $query);
302
303
        return $query->count();
304
    }
305
306
    /**
307
     * Get last notification of the current
@@ 315-323 (lines=9) @@
312
     * @param Closure $filterScope
313
     * @return mixed
314
     */
315
    public function getLastNotification($to_id, $entity, Closure $filterScope = null)
316
    {
317
        $query = $this->notification->wherePolymorphic($to_id, $entity)
318
            ->orderBy('created_at', 'DESC');
319
320
        $query = $this->applyFilter($filterScope, $query);
321
322
        return $query->first();
323
    }
324
325
    /**
326
     * Get last notification of the current
@@ 335-345 (lines=11) @@
332
     * @param Closure $filterScope
333
     * @return mixed
334
     */
335
    public function getLastNotificationByCategory($category, $to_id, $entity, Closure $filterScope = null)
336
    {
337
        $query = $this->notification
338
            ->wherePolymorphic($to_id, $entity)
339
            ->byCategory($category)
340
            ->orderBy('created_at', 'desc');
341
342
        $query = $this->applyFilter($filterScope, $query);
343
344
        return $query->first();
345
    }
346
347
    /**
348
     * Apply scope filters