Completed
Push — master ( 5c8f9b...c72a1f )
by Christopher
01:11
created

Comment::approve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Chriscreates\Blog;
4
5
use Chriscreates\Blog\Builders\CommentBuilder;
6
use Chriscreates\Blog\Traits\Comment\CommentApproval;
7
use Chriscreates\Blog\Traits\IsAuthorable;
8
use Illuminate\Database\Eloquent\Model;
9
10
class Comment extends Model
11
{
12
    use CommentApproval,
13
    IsAuthorable;
14
15
    protected $table = 'comments';
16
17
    protected $primaryKey = 'id';
18
19
    public $guarded = ['id'];
20
21
    public $timestamps = true;
22
23
    protected $casts = [
24
        'is_approved' => 'boolean',
25
    ];
26
27
    public function commentable()
28
    {
29
        return $this->morphTo();
30
    }
31
32
    public function approve()
33
    {
34
        $this->update(['is_approved' => true]);
35
36
        return $this;
37
    }
38
39
    public function disapprove()
40
    {
41
        $this->update(['is_approved' => false]);
42
43
        return $this;
44
    }
45
46
    public function newEloquentBuilder($query) : CommentBuilder
47
    {
48
        return new CommentBuilder($query);
49
    }
50
}
51