Like   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A likeable() 0 3 1
A author() 0 3 1
1
<?php
2
3
namespace Turahe\Likeable\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
use Turahe\Likeable\Contracts\Like as LikeContract;
8
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
10
/**
11
 * Class Like.
12
 */
13
class Like extends Model implements LikeContract
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $table = 'likes';
19
    /**
20
     * @var string[]
21
     */
22
    protected $fillable = [
23
        'user_id',
24
        'type_id',
25
    ];
26
27
    public function likeable(): MorphTo
28
    {
29
        return $this->morphTo();
30
    }
31
32
    /**
33
     * Return the like's author.
34
     */
35
    public function author(): BelongsTo
36
    {
37
        return $this->belongsTo(config('auth.providers.users.model'), 'user_id');
38
    }
39
}
40