]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Entity.php
Update maintenance.php
[bookstack] / app / Entities / Entity.php
index 7917f83f83648f95aa3a2daa0741d0a018e00647..482d217662ae20b54f62578d88367b8daacb1098 100644 (file)
@@ -102,6 +102,11 @@ class Entity extends Ownable
         return $this->morphMany(View::class, 'viewable');
     }
 
+    public function viewCountQuery()
+    {
+        return $this->views()->selectRaw('viewable_id, sum(views) as view_count')->groupBy('viewable_id');
+    }
+
     /**
      * Get the Tag models that have been user assigned to this entity.
      * @return \Illuminate\Database\Eloquent\Relations\MorphMany
@@ -229,7 +234,7 @@ class Entity extends Ownable
         if (mb_strlen($text) > $length) {
             $text = mb_substr($text, 0, $length-3) . '...';
         }
-        return  trim($text);
+        return trim($text);
     }
 
     /**