X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f1e571a57c03b4d1985f863443fff510cd95e0db..refs/pull/1462/head:/app/Entities/Book.php diff --git a/app/Entities/Book.php b/app/Entities/Book.php index 3bce3860c..77cacf632 100644 --- a/app/Entities/Book.php +++ b/app/Entities/Book.php @@ -69,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 @@ -92,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;