]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Queries/PageQueries.php
System CLI: Updated to 126de5599c state
[bookstack] / app / Entities / Queries / PageQueries.php
index ec27ba4aa6e3e6302d511c0eefe43b9c1d4c8622..06298f470b902f8abfef4257c108a0fa42f1ecb5 100644 (file)
@@ -10,11 +10,12 @@ class PageQueries implements ProvidesEntityQueries
 {
     protected static array $contentAttributes = [
         'name', 'id', 'slug', 'book_id', 'chapter_id', 'draft',
-        'template', 'html', 'text', 'created_at', 'updated_at', 'priority'
+        'template', 'html', 'text', 'created_at', 'updated_at', 'priority',
+        'created_by', 'updated_by', 'owned_by',
     ];
     protected static array $listAttributes = [
         'name', 'id', 'slug', 'book_id', 'chapter_id', 'draft',
-        'template', 'text', 'created_at', 'updated_at', 'priority'
+        'template', 'text', 'created_at', 'updated_at', 'priority', 'owned_by',
     ];
 
     public function start(): Builder
@@ -50,7 +51,7 @@ class PageQueries implements ProvidesEntityQueries
             ->first();
 
         if (is_null($page)) {
-            throw new NotFoundException(trans('errors.chapter_not_found'));
+            throw new NotFoundException(trans('errors.page_not_found'));
         }
 
         return $page;
@@ -72,6 +73,14 @@ class PageQueries implements ProvidesEntityQueries
             ->select($this->mergeBookSlugForSelect(static::$listAttributes));
     }
 
+    public function visibleForChapterList(int $chapterId): Builder
+    {
+        return $this->visibleForList()
+            ->where('chapter_id', '=', $chapterId)
+            ->orderBy('draft', 'desc')
+            ->orderBy('priority', 'asc');
+    }
+
     public function visibleWithContents(): Builder
     {
         return $this->start()