LikeDislike   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 67
ccs 4
cts 8
cp 0.5
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A video() 0 4 1
A scopeLikes() 0 4 1
A scopeDislikes() 0 4 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class LikeDislike.
9
 */
10
class LikeDislike extends Model
11
{
12
    /**
13
     * Table name.
14
     *
15
     * @var string
16
     */
17
    protected $table = 'likes_dislikes';
18
19
    /**
20
     * The attributes that are mass assignable.
21
     *
22
     * @var array
23
     */
24
    protected $fillable = ['user_id', 'video_id', 'type'];
25
26
    /**
27
     * The attributes that should be hidden for arrays.
28
     *
29
     * @var array
30
     */
31
    protected $hidden = [];
32
33
    /**
34
     * User relation.
35
     *
36
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
37
     */
38
    public function user()
39
    {
40
        return $this->belongsTo(\App\User::class);
41
    }
42
43
    /**
44
     * Video relation.
45
     *
46
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
47
     */
48
    public function video()
49
    {
50
        return $this->belongsTo(\App\Video::class);
51
    }
52
53
    /**
54
     * Return all instances when type is likes.
55
     *
56
     * @param $query
57
     *
58
     * @return mixed
59
     */
60 8
    public function scopeLikes($query)
61
    {
62 8
        return $query->where('type', 'like');
63
    }
64
65
    /**
66
     * Return all instances when type is dislikes.
67
     *
68
     * @param $query
69
     *
70
     * @return mixed
71
     */
72 8
    public function scopeDislikes($query)
73
    {
74 8
        return $query->where('type', 'dislike');
75
    }
76
}
77