Total Complexity | 5 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Comment extends Model |
||
11 | { |
||
12 | public $casts = [ |
||
13 | 'approved' => 'boolean', |
||
14 | ]; |
||
15 | |||
16 | public $fillable = [ |
||
17 | 'comment', |
||
18 | 'author_name', |
||
19 | ]; |
||
20 | |||
21 | protected $table = 'blog_etc_comments'; |
||
22 | |||
23 | /** |
||
24 | * The "booting" method of the model. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | protected static function boot() |
||
29 | { |
||
30 | parent::boot(); |
||
31 | |||
32 | static::addGlobalScope(new BlogCommentApprovedAndDefaultOrderScope()); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * The associated Post for this comment.. |
||
37 | * |
||
38 | * @return BelongsTo |
||
39 | */ |
||
40 | public function post(): BelongsTo |
||
41 | { |
||
42 | return $this->belongsTo(Post::class, 'blog_etc_post_id'); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Comment author user (if set). |
||
47 | * |
||
48 | * @return BelongsTo |
||
49 | */ |
||
50 | public function user(): BelongsTo |
||
51 | { |
||
52 | return $this->belongsTo(User::class); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Return author string (either from the User (via ->user_id), or the submitted author_name value. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function author() |
||
69 | } |
||
70 | } |
||
71 |