22
33namespace BookStack \Entities \Models ;
44
5- use BookStack \Uploads \Image ;
65use Exception ;
76use Illuminate \Database \Eloquent \Factories \HasFactory ;
8- use Illuminate \Database \Eloquent \Relations \BelongsTo ;
97use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
108
11- class Bookshelf extends Entity implements CoverImageInterface, HtmlDescriptionInterface
9+ class Bookshelf extends Entity
1210{
1311 use HasFactory;
14- use HtmlDescriptionTrait;
1512
1613 public float $ searchFactor = 1.2 ;
1714
18- protected $ fillable = ['name ' , 'description ' , 'image_id ' ];
19-
2015 protected $ hidden = ['image_id ' , 'deleted_at ' , 'description_html ' ];
2116
2217 /**
2318 * Get the books in this shelf.
24- * Should not be used directly since does not take into account permissions.
19+ * Should not be used directly since it does not take into account permissions.
2520 */
2621 public function books (): BelongsToMany
2722 {
@@ -53,34 +48,17 @@ public function getBookCover(int $width = 440, int $height = 250): string
5348 {
5449 // TODO - Make generic, focused on books right now, Perhaps set-up a better image
5550 $ default = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== ' ;
56- if (!$ this ->image_id || !$ this ->cover ) {
51+ if (!$ this ->containerData -> image_id || !$ this -> containerData ->cover ) {
5752 return $ default ;
5853 }
5954
6055 try {
61- return $ this ->cover ->getThumb ($ width , $ height , false ) ?? $ default ;
56+ return $ this ->containerData -> cover ->getThumb ($ width , $ height , false ) ?? $ default ;
6257 } catch (Exception $ err ) {
6358 return $ default ;
6459 }
6560 }
6661
67- /**
68- * Get the cover image of the shelf.
69- * @return BelongsTo<Image, $this>
70- */
71- public function cover (): BelongsTo
72- {
73- return $ this ->belongsTo (Image::class, 'image_id ' );
74- }
75-
76- /**
77- * Get the type of the image model that is used when storing a cover image.
78- */
79- public function coverImageTypeKey (): string
80- {
81- return 'cover_bookshelf ' ;
82- }
83-
8462 /**
8563 * Check if this shelf contains the given book.
8664 */
@@ -92,7 +70,7 @@ public function contains(Book $book): bool
9270 /**
9371 * Add a book to the end of this shelf.
9472 */
95- public function appendBook (Book $ book )
73+ public function appendBook (Book $ book ): void
9674 {
9775 if ($ this ->contains ($ book )) {
9876 return ;
0 commit comments