BookStack/app/Book.php

36 lines
652 B
PHP
Raw Normal View History

2015-07-12 19:01:42 +00:00
<?php
namespace BookStack;
2015-07-12 19:01:42 +00:00
class Book extends Entity
2015-07-12 19:01:42 +00:00
{
protected $fillable = ['name', 'description'];
public function getUrl()
{
return '/books/' . $this->slug;
}
public function getEditUrl()
{
return $this->getUrl() . '/edit';
}
2015-07-12 20:31:15 +00:00
public function pages()
{
return $this->hasMany('BookStack\Page');
2015-07-12 20:31:15 +00:00
}
2015-07-27 19:17:08 +00:00
public function chapters()
{
return $this->hasMany('BookStack\Chapter');
2015-07-27 19:17:08 +00:00
}
public function getExcerpt($length = 100)
{
return strlen($this->description) > $length ? substr($this->description, 0, $length-3) . '...' : $this->description;
}
2015-07-12 19:01:42 +00:00
}