]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Book.php
Update maintenance.php
[bookstack] / app / Entities / Book.php
index b8a29322d6b58f52bc142104312e79209a935f0b..77cacf632e03dad04c6b9dcec98843170e046224 100644 (file)
@@ -1,7 +1,6 @@
 <?php namespace BookStack\Entities;
 
 use BookStack\Uploads\Image;
-use BookStack\Entities\Page;
 
 class Book extends Entity
 {
@@ -39,7 +38,7 @@ class Book extends Entity
      */
     public function getBookCover($width = 440, $height = 250)
     {
-        $default = baseUrl('/book_default_cover.png');
+        $default = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
         if (!$this->image_id) {
             return $default;
         }
@@ -70,6 +69,15 @@ class Book extends Entity
         return $this->hasMany(Page::class);
     }
 
+    /**
+     * Get the direct child pages of this book.
+     * @return \Illuminate\Database\Eloquent\Relations\HasMany
+     */
+    public function directPages()
+    {
+        return $this->pages()->where('chapter_id', '=', '0');
+    }
+
     /**
      * Get all chapters within this book.
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -93,7 +101,7 @@ class Book extends Entity
      * @param int $length
      * @return string
      */
-    public function getExcerpt($length = 100)
+    public function getExcerpt(int $length = 100)
     {
         $description = $this->description;
         return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;