]> BookStack Code Mirror - bookstack/blobdiff - app/Chapter.php
Add Carbon localization support
[bookstack] / app / Chapter.php
index 08faef68e390e8bb2c547713826bdcee2d7ff0d0..cc5518b7a831ea73a41681043a3deddeb214d946 100644 (file)
@@ -25,12 +25,16 @@ class Chapter extends Entity
 
     /**
      * Get the url of this chapter.
+     * @param string|bool $path
      * @return string
      */
-    public function getUrl()
+    public function getUrl($path = false)
     {
         $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug;
-        return '/books/' . $bookSlug. '/chapter/' . $this->slug;
+        if ($path !== false) {
+            return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug) . '/' . trim($path, '/'));
+        }
+        return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug));
     }
 
     /**