]> BookStack Code Mirror - bookstack/blobdiff - app/Entity.php
Adds test cases and fixes an issue with the permission checking.
[bookstack] / app / Entity.php
index efbbf0eba36ace6d04fa517873890f782b08bd8d..df8e4d38b241e9928ca951697b6da392744a39e2 100644 (file)
@@ -69,14 +69,15 @@ class Entity extends Ownable
 
     /**
      * Get the comments for an entity
-     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+     * @param bool $orderByCreated
+     * @return MorphMany
      */
-    public function comments()
+    public function comments($orderByCreated = true)
     {
-        return $this->morphMany(Comment::class, 'entity')->orderBy('created_at', 'asc');
+        $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