2
2
3
3
namespace BookStack \Entities \Models ;
4
4
5
- use BookStack \Uploads \Image ;
6
5
use Exception ;
7
6
use Illuminate \Database \Eloquent \Factories \HasFactory ;
8
- use Illuminate \Database \Eloquent \Relations \BelongsTo ;
9
7
use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
10
8
11
- class Bookshelf extends Entity implements CoverImageInterface, HtmlDescriptionInterface
9
+ class Bookshelf extends Entity
12
10
{
13
11
use HasFactory;
14
- use HtmlDescriptionTrait;
15
12
16
13
public float $ searchFactor = 1.2 ;
17
14
18
- protected $ fillable = ['name ' , 'description ' , 'image_id ' ];
19
-
20
15
protected $ hidden = ['image_id ' , 'deleted_at ' , 'description_html ' ];
21
16
22
17
/**
23
18
* 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.
25
20
*/
26
21
public function books (): BelongsToMany
27
22
{
@@ -53,34 +48,17 @@ public function getBookCover(int $width = 440, int $height = 250): string
53
48
{
54
49
// TODO - Make generic, focused on books right now, Perhaps set-up a better image
55
50
$ default = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== ' ;
56
- if (!$ this ->image_id || !$ this ->cover ) {
51
+ if (!$ this ->containerData -> image_id || !$ this -> containerData ->cover ) {
57
52
return $ default ;
58
53
}
59
54
60
55
try {
61
- return $ this ->cover ->getThumb ($ width , $ height , false ) ?? $ default ;
56
+ return $ this ->containerData -> cover ->getThumb ($ width , $ height , false ) ?? $ default ;
62
57
} catch (Exception $ err ) {
63
58
return $ default ;
64
59
}
65
60
}
66
61
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
-
84
62
/**
85
63
* Check if this shelf contains the given book.
86
64
*/
@@ -92,7 +70,7 @@ public function contains(Book $book): bool
92
70
/**
93
71
* Add a book to the end of this shelf.
94
72
*/
95
- public function appendBook (Book $ book )
73
+ public function appendBook (Book $ book ): void
96
74
{
97
75
if ($ this ->contains ($ book )) {
98
76
return ;
0 commit comments