]> BookStack Code Mirror - bookstack/blob - app/Actions/Comment.php
Fixed the `AddActivityIndexes` migration's `down()` method
[bookstack] / app / Actions / Comment.php
1 <?php namespace BookStack\Actions;
2
3 use BookStack\Ownable;
4
5 /**
6  * @property string text
7  * @property string html
8  * @property int|null parent_id
9  * @property int local_id
10  */
11 class Comment extends Ownable
12 {
13     protected $fillable = ['text', 'parent_id'];
14     protected $appends = ['created', 'updated'];
15
16     /**
17      * Get the entity that this comment belongs to
18      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
19      */
20     public function entity()
21     {
22         return $this->morphTo('entity');
23     }
24
25     /**
26      * Check if a comment has been updated since creation.
27      * @return bool
28      */
29     public function isUpdated()
30     {
31         return $this->updated_at->timestamp > $this->created_at->timestamp;
32     }
33
34     /**
35      * Get created date as a relative diff.
36      * @return mixed
37      */
38     public function getCreatedAttribute()
39     {
40         return $this->created_at->diffForHumans();
41     }
42
43     /**
44      * Get updated date as a relative diff.
45      * @return mixed
46      */
47     public function getUpdatedAttribute()
48     {
49         return $this->updated_at->diffForHumans();
50     }
51 }