Test Failed
Push — master ( d4bdb3...458817 )
by Marcel
01:05
created

CheckRateableHelper::checkRateable()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 3
eloc 11
nc 2
nop 3
1
<?php
2
3
namespace App\Helpers;
4
5
class CheckRateableHelper
6
{
7
    public static function checkRateable($content_type, $content_id, $user_id)
8
    {
9
        $comments = \DB::table('comments')
10
            ->selectRaw('SUM(comments.vote_up) as up, SUM(comments.vote_down) as down')
11
            ->where('comments.content_id', '=', $content_id)
12
            ->where('comments.content_type', '=', $content_type)
13
            ->where('comments.user_id', '=', $user_id)
14
            ->first();
15
16
        if ($comments->up > 0 || $comments->down > 0) {
17
            return false;
18
        } else {
19
            return true;
20
        }
21
    }
22
}
23