X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ef1b98019a0c3f123b0add8428292807eac3fe05..refs/pull/2511/head:/app/Entities/Models/Chapter.php diff --git a/app/Entities/Models/Chapter.php b/app/Entities/Models/Chapter.php index 4514bef03..257b19e37 100644 --- a/app/Entities/Models/Chapter.php +++ b/app/Entities/Models/Chapter.php @@ -1,7 +1,5 @@ getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug; - $fullPath = '/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug); - - if ($path !== false) { - $fullPath .= '/' . trim($path, '/'); - } - - return url($fullPath); - } - - /** - * Get an excerpt of this chapter's description to the specified length or less. - * @param int $length - * @return string - */ - public function getExcerpt(int $length = 100) - { - $description = $this->text ?? $this->description; - return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description; - } - - /** - * Check if this chapter has any child pages. - * @return bool - */ - public function hasChildren() - { - return count($this->pages) > 0; + $parts = [ + 'books', + urlencode($this->getAttribute('bookSlug') ?? $this->book->slug), + 'chapter', + urlencode($this->slug), + trim($path, '/'), + ]; + + return url('/' . implode('/', $parts)); } /**