X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/397db0442853bcca281687fd2f97614e925d0dfd..refs/pull/691/head:/app/Comment.php diff --git a/app/Comment.php b/app/Comment.php index 9ef892bdc..2800ab21a 100644 --- a/app/Comment.php +++ b/app/Comment.php @@ -1,11 +1,10 @@ -morphTo('entity'); } - + /** - * Get the page that this comment is in. - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * Check if a comment has been updated since creation. + * @return bool */ - public function page() + public function isUpdated() { - return $this->belongsTo(Page::class); + return $this->updated_at->timestamp > $this->created_at->timestamp; } - + + /** + * Get created date as a relative diff. + * @return mixed + */ + public function getCreatedAttribute() + { + return $this->created_at->diffForHumans(); + } + /** - * Get the owner of this comment. - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * Get updated date as a relative diff. + * @return mixed */ - public function user() + public function getUpdatedAttribute() { - return $this->belongsTo(User::class); + return $this->updated_at->diffForHumans(); } }