File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 16
16
],
17
17
],
18
18
],
19
- 'book_visual_placeholder_url ' => asset ('/img/book-placeholder.png ' ),
20
19
];
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class Book extends Model implements JsonSerializable
22
22
'availability ' => BookAvailability::class,
23
23
];
24
24
25
+ protected static ?string $ fallbackVisualUrl = null ;
26
+
25
27
protected static function newFactory ()
26
28
{
27
29
return new BookFactory ;
@@ -64,17 +66,22 @@ public function canBeOrdered(): bool
64
66
&& ($ this ->hasStock () || $ this ->availability == BookAvailability::AvailableOnDemand);
65
67
}
66
68
67
- public function visual (string $ size , ?string $ placeholder = null ): ?string
69
+ public function visual (string $ size , ?string $ fallbackUrl = null ): ?string
68
70
{
69
71
$ url = $ this ->visuals [$ size ] ?? null ;
70
72
71
73
if (preg_match ('/no_image\.png/ ' , $ url )) {
72
- return $ placeholder ?? config ( ' titelive-client.book_visual_placeholder_url ' );
74
+ return $ fallbackUrl ?: static :: $ fallbackVisualUrl ?: asset ( ' /img/book-placeholder.png ' );
73
75
}
74
76
75
77
return $ url ;
76
78
}
77
79
80
+ public static function setFallbackVisualUrl (string $ url ): void
81
+ {
82
+ static ::$ fallbackVisualUrl = $ url ;
83
+ }
84
+
78
85
public function jsonSerialize (): array
79
86
{
80
87
return (new BookJsonResource ($ this ))->jsonSerialize ();
You can’t perform that action at this time.
0 commit comments