]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Models/Chapter.php
Added 'Sort Book' action to chapters
[bookstack] / app / Entities / Models / Chapter.php
index 75630832b46a77d626afba127f676d4b48f4a8b3..af4bbd8e3a66238d722272358086aa45f4aa970d 100644 (file)
@@ -10,19 +10,21 @@ use Illuminate\Support\Collection;
  * Class Chapter.
  *
  * @property Collection<Page> $pages
- * @property string $description
+ * @property string           $description
  */
 class Chapter extends BookChild
 {
     use HasFactory;
 
-    public $searchFactor = 1.3;
+    public $searchFactor = 1.2;
 
-    protected $fillable = ['name', 'description', 'priority', 'book_id'];
+    protected $fillable = ['name', 'description', 'priority'];
     protected $hidden = ['restricted', 'pivot', 'deleted_at'];
 
     /**
      * Get the pages that this chapter contains.
+     *
+     * @return HasMany<Page>
      */
     public function pages(string $dir = 'ASC'): HasMany
     {
@@ -50,7 +52,8 @@ class Chapter extends BookChild
      */
     public function getVisiblePages(): Collection
     {
-        return $this->pages()->visible()
+        return $this->pages()
+        ->scopes('visible')
         ->orderBy('draft', 'desc')
         ->orderBy('priority', 'asc')
         ->get();