]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Book.php
Show bookshelves that a book belongs to on a book view
[bookstack] / app / Entities / Book.php
index e722c4b107dc5dd3ea1262b7672e14bc7f9ef32e..ce4c4b90e08229a9b2e9efc690a14b7c68887f40 100644 (file)
@@ -2,6 +2,13 @@
 
 use BookStack\Uploads\Image;
 
+/**
+ * Class Book
+ * @property string $description
+ * @property int $image_id
+ * @property Image|null $cover
+ * @package BookStack\Entities
+ */
 class Book extends Entity
 {
     public $searchFactor = 2;
@@ -25,9 +32,9 @@ class Book extends Entity
     public function getUrl($path = false)
     {
         if ($path !== false) {
-            return baseUrl('/books/' . urlencode($this->slug) . '/' . trim($path, '/'));
+            return url('/books/' . urlencode($this->slug) . '/' . trim($path, '/'));
         }
-        return baseUrl('/books/' . urlencode($this->slug));
+        return url('/books/' . urlencode($this->slug));
     }
 
     /**
@@ -44,7 +51,7 @@ class Book extends Entity
         }
 
         try {
-            $cover = $this->cover ? baseUrl($this->cover->getThumb($width, $height, false)) : $default;
+            $cover = $this->cover ? url($this->cover->getThumb($width, $height, false)) : $default;
         } catch (\Exception $err) {
             $cover = $default;
         }
@@ -101,10 +108,10 @@ class Book extends Entity
      * @param int $length
      * @return string
      */
-    public function getExcerpt($length = 100)
+    public function getExcerpt(int $length = 100)
     {
         $description = $this->description;
-        return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;
+        return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description;
     }
 
     /**