]> BookStack Code Mirror - bookstack/blob - app/Book.php
Closes #69. Implemented and tested memcached.
[bookstack] / app / Book.php
1 <?php
2
3 namespace BookStack;
4
5 class Book extends Entity
6 {
7
8     protected $fillable = ['name', 'description'];
9
10     public function getUrl()
11     {
12         return '/books/' . $this->slug;
13     }
14
15     public function getEditUrl()
16     {
17         return $this->getUrl() . '/edit';
18     }
19
20     public function pages()
21     {
22         return $this->hasMany('BookStack\Page');
23     }
24
25     public function chapters()
26     {
27         return $this->hasMany('BookStack\Chapter');
28     }
29
30     public function getExcerpt($length = 100)
31     {
32         return strlen($this->description) > $length ? substr($this->description, 0, $length-3) . '...' : $this->description;
33     }
34
35 }