]> BookStack Code Mirror - bookstack/blob - app/Actions/Comment.php
Updated existing image tests to reflect changes
[bookstack] / app / Actions / Comment.php
1 <?php namespace BookStack\Actions;
2
3 use BookStack\Ownable;
4
5 class Comment extends Ownable
6 {
7     protected $fillable = ['text', 'html', 'parent_id'];
8     protected $appends = ['created', 'updated'];
9
10     /**
11      * Get the entity that this comment belongs to
12      * @return \Illuminate\Database\Eloquent\Relations\MorphTo
13      */
14     public function entity()
15     {
16         return $this->morphTo('entity');
17     }
18
19     /**
20      * Check if a comment has been updated since creation.
21      * @return bool
22      */
23     public function isUpdated()
24     {
25         return $this->updated_at->timestamp > $this->created_at->timestamp;
26     }
27
28     /**
29      * Get created date as a relative diff.
30      * @return mixed
31      */
32     public function getCreatedAttribute()
33     {
34         return $this->created_at->diffForHumans();
35     }
36
37     /**
38      * Get updated date as a relative diff.
39      * @return mixed
40      */
41     public function getUpdatedAttribute()
42     {
43         return $this->updated_at->diffForHumans();
44     }
45 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.