Completed
Branch master (a6481d)
by Fèvre
02:09
created

Comment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 48
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A countCaches() 0 7 1
A user() 0 4 1
A article() 0 4 1
1
<?php
2
namespace Xetaravel\Models;
3
4
use Xetaravel\Models\Article;
5
use Xetaravel\Models\User;
6
use Eloquence\Behaviours\CountCache\Countable;
7
8
class Comment extends Model
9
{
10
    use Countable;
11
12
    /**
13
     * The attributes that are mass assignable.
14
     *
15
     * @var array
16
     */
17
    protected $fillable = [
18
        'article_id',
19
        'user_id',
20
        'content'
21
    ];
22
23
    /**
24
     * Return the count cache configuration.
25
     *
26
     * @return array
27
     */
28
    public function countCaches(): array
29
    {
30
        return [
31
            User::class,
32
            Article::class
33
        ];
34
    }
35
36
    /**
37
     * Get the user that owns the comment.
38
     *
39
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
40
     */
41
    public function user()
42
    {
43
        return $this->belongsTo('Xetaravel\Models\User');
44
    }
45
46
    /**
47
     * Get the article that owns the comment.
48
     *
49
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
50
     */
51
    public function article()
52
    {
53
        return $this->belongsTo('Xetaravel\Models\Article');
54
    }
55
}
56