X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1859a4d356cc7452bc5461de904977f05f4c55d1..refs/pull/635/head:/app/Entity.php diff --git a/app/Entity.php b/app/Entity.php index e5dd04bf2..df8e4d38b 100644 --- a/app/Entity.php +++ b/app/Entity.php @@ -1,6 +1,8 @@ morphMany(Tag::class, 'entity')->orderBy('order', 'asc'); } + /** + * Get the comments for an entity + * @param bool $orderByCreated + * @return MorphMany + */ + public function comments($orderByCreated = true) + { + $query = $this->morphMany(Comment::class, 'entity'); + return $orderByCreated ? $query->orderBy('created_at', 'asc') : $query; + } + /** * Get the related search terms. * @return \Illuminate\Database\Eloquent\Relations\MorphMany