X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c7a2d568bf693add30c8402d68d1f46f09a44c5b..refs/pull/2700/head:/app/Entities/Models/Chapter.php diff --git a/app/Entities/Models/Chapter.php b/app/Entities/Models/Chapter.php index 69dafe8ac..257b19e37 100644 --- a/app/Entities/Models/Chapter.php +++ b/app/Entities/Models/Chapter.php @@ -1,4 +1,4 @@ -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)); } /**