+ return $this->belongsTo(Book::class);
+ }
+
+ /**
+ * Get the chapter that this page is in, If applicable.
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function chapter()
+ {
+ return $this->belongsTo(Chapter::class);
+ }
+
+ /**
+ * Check if this page has a chapter.
+ * @return bool
+ */
+ public function hasChapter()
+ {
+ return $this->chapter()->count() > 0;
+ }
+
+ /**
+ * Get the associated page revisions, ordered by created date.
+ * @return mixed
+ */
+ public function revisions()
+ {
+ return $this->hasMany(PageRevision::class)->where('type', '=', 'version')->orderBy('created_at', 'desc');