+ if ($path !== false) {
+ return baseUrl('/books/' . urlencode($this->slug) . '/' . trim($path, '/'));
+ }
+ return baseUrl('/books/' . urlencode($this->slug));
+ }
+
+ /**
+ * Returns book cover image, if book cover not exists return default cover image.
+ * @param int $width - Width of the image
+ * @param int $height - Height of the image
+ * @return string
+ */
+ public function getBookCover($width = 440, $height = 250)
+ {
+ $default = baseUrl('/book_default_cover.png');
+ if (!$this->image_id) {
+ return $default;
+ }
+
+ try {
+ $cover = $this->cover ? baseUrl($this->cover->getThumb($width, $height, false)) : $default;
+ } catch (\Exception $err) {
+ $cover = $default;
+ }
+ return $cover;