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