Passed
Push — 5.0.0 ( f07a46...357374 )
by Fèvre
05:39
created

Comment::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models;
6
7
use Eloquence\Behaviours\CountCache\CountedBy;
8
use Eloquence\Behaviours\CountCache\HasCounts;
9
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11
use Xetaio\Mentions\Models\Traits\HasMentionsTrait;
12
use Xetaravel\Models\Gates\FloodGate;
13
use Xetaravel\Models\Presenters\CommentPresenter;
14
use Xetaravel\Observers\CommentObserver;
15
16
#[ObservedBy([CommentObserver::class])]
17
class Comment extends Model
18
{
19
    use CommentPresenter;
0 ignored issues
show
Bug introduced by
The trait Xetaravel\Models\Presenters\CommentPresenter requires the property $content which is not provided by Xetaravel\Models\Comment.
Loading history...
20
    use FloodGate;
21
    use HasCounts;
22
    use HasMentionsTrait;
23
24
    /**
25
     * The attributes that are mass assignable.
26
     *
27
     * @var array
28
     */
29
    protected $fillable = [
30
        'article_id',
31
        'user_id',
32
        'content'
33
    ];
34
35
    /**
36
     * The accessors to append to the model's array form.
37
     *
38
     * @var array
39
     */
40
    protected $appends = [
41
        'content_markdown',
42
        'comment_url'
43
    ];
44
45
    /**
46
     * Get the user that owns the comment.
47
     *
48
     * @return BelongsTo
49
     */
50
    #[CountedBy]
51
    public function user(): BelongsTo
52
    {
53
        return $this->belongsTo(User::class);
54
    }
55
56
    /**
57
     * Get the article that owns the comment.
58
     *
59
     * @return BelongsTo
60
     */
61
    #[CountedBy]
62
    public function article(): BelongsTo
63
    {
64
        return $this->belongsTo(Article::class);
65
    }
66
}
67