5 class Book extends Entity
8 protected $fillable = ['name', 'description'];
10 public function getUrl()
12 return '/books/' . $this->slug;
15 public function getEditUrl()
17 return $this->getUrl() . '/edit';
20 public function pages()
22 return $this->hasMany('Oxbow\Page');
25 public function chapters()
27 return $this->hasMany('Oxbow\Chapter');
30 public function children()
32 $pages = $this->pages()->where('chapter_id', '=', 0)->get();
33 $chapters = $this->chapters()->get();
34 foreach($chapters as $chapter) {
35 $pages->push($chapter);
37 return $pages->sortBy('priority');