mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 07:32:39 +01:00
41 lines
745 B
PHP
41 lines
745 B
PHP
<?php
|
|
|
|
namespace Oxbow;
|
|
|
|
class Book extends Entity
|
|
{
|
|
|
|
protected $fillable = ['name', 'description'];
|
|
|
|
public function getUrl()
|
|
{
|
|
return '/books/' . $this->slug;
|
|
}
|
|
|
|
public function getEditUrl()
|
|
{
|
|
return $this->getUrl() . '/edit';
|
|
}
|
|
|
|
public function pages()
|
|
{
|
|
return $this->hasMany('Oxbow\Page');
|
|
}
|
|
|
|
public function chapters()
|
|
{
|
|
return $this->hasMany('Oxbow\Chapter');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
$pages = $this->pages()->where('chapter_id', '=', 0)->get();
|
|
$chapters = $this->chapters()->get();
|
|
foreach($chapters as $chapter) {
|
|
$pages->push($chapter);
|
|
}
|
|
return $pages->sortBy('priority');
|
|
}
|
|
|
|
}
|