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
* @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;