1 <?php namespace BookStack\Actions;
4 use BookStack\Traits\HasCreatorAndUpdater;
5 use Illuminate\Database\Eloquent\Relations\MorphTo;
8 * @property string text
9 * @property string html
10 * @property int|null parent_id
11 * @property int local_id
13 class Comment extends Model
15 use HasCreatorAndUpdater;
17 protected $fillable = ['text', 'parent_id'];
18 protected $appends = ['created', 'updated'];
21 * Get the entity that this comment belongs to
23 public function entity(): MorphTo
25 return $this->morphTo('entity');
29 * Check if a comment has been updated since creation.
31 public function isUpdated(): bool
33 return $this->updated_at->timestamp > $this->created_at->timestamp;
37 * Get created date as a relative diff.
40 public function getCreatedAttribute()
42 return $this->created_at->diffForHumans();
46 * Get updated date as a relative diff.
49 public function getUpdatedAttribute()
51 return $this->updated_at->diffForHumans();