Completed
Pull Request — master (#34)
by Fèvre
06:03 queued 03:09
created

DiscussComment::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Xetaravel\Models;
3
4
use Eloquence\Behaviours\CountCache\Countable;
5
use Xetaio\Mentions\Models\Traits\HasMentionsTrait;
6
use Xetaravel\Models\Presenters\DiscussCommentPresenter;
7
use Xetaravel\Models\User;
8
9 View Code Duplication
class DiscussComment extends Model
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    use Countable,
12
        DiscussCommentPresenter,
13
        HasMentionsTrait;
14
15
    /**
16
     * The attributes that are mass assignable.
17
     *
18
     * @var array
19
     */
20
    protected $fillable = [
21
        'user_id',
22
        'thread_id',
23
        'content',
24
        'is_edited'
25
    ];
26
27
    /**
28
     * The accessors to append to the model's array form.
29
     *
30
     * @var array
31
     */
32
    protected $appends = [
33
        'content_markdown',
34
        'comment_url'
35
    ];
36
37
    /**
38
     * Return the count cache configuration.
39
     *
40
     * @return array
41
     */
42
    public function countCaches(): array
43
    {
44
        return [
45
            User::class,
46
            DiscussThread::class
47
        ];
48
    }
49
50
    /**
51
     * Get the user that owns the comment.
52
     *
53
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
54
     */
55
    public function user()
56
    {
57
        return $this->belongsTo(User::class);
58
    }
59
60
    /**
61
     * Get the thread that owns the comment.
62
     *
63
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
64
     */
65
    public function thread()
66
    {
67
        return $this->belongsTo(DiscussThread::class);
68
    }
69
}
70