BookStack/app/Chapter.php

30 lines
647 B
PHP
Raw Normal View History

<?php namespace BookStack;
2015-07-27 19:17:08 +00:00
class Chapter extends Entity
2015-07-27 19:17:08 +00:00
{
protected $fillable = ['name', 'description', 'priority', 'book_id'];
public function book()
{
return $this->belongsTo('BookStack\Book');
2015-07-27 19:17:08 +00:00
}
public function pages()
2015-07-27 19:17:08 +00:00
{
return $this->hasMany('BookStack\Page')->orderBy('priority', 'ASC');
2015-07-27 19:17:08 +00:00
}
public function getUrl()
{
return '/books/' . $this->book->slug . '/chapter/' . $this->slug;
}
public function getExcerpt($length = 100)
{
return strlen($this->description) > $length ? substr($this->description, 0, $length-3) . '...' : $this->description;
}
2015-07-27 19:17:08 +00:00
}