File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 3
3
namespace Code16 \LaravelTiteliveClient \Utils ;
4
4
5
5
use Code16 \LaravelTiteliveClient \Api \Clients \BookCache ;
6
+ use Code16 \LaravelTiteliveClient \Api \Clients \TiteLive \TiteLiveBookNotFoundException ;
6
7
use Code16 \LaravelTiteliveClient \Book ;
7
8
use Illuminate \Database \Eloquent \Casts \Attribute ;
8
9
@@ -13,11 +14,15 @@ trait HasBookAttribute
13
14
{
14
15
public function refreshBook (bool $ force = false ): self
15
16
{
16
- $ this ->update ([
17
- 'book ' => app (BookCache::class)
18
- ->force ($ force )
19
- ->refreshIfNeeded ($ this ->book ),
20
- ]);
17
+ try {
18
+ $ this ->update ([
19
+ 'book ' => $ refreshedBook = app (BookCache::class)
20
+ ->force ($ force )
21
+ ->refreshIfNeeded ($ this ->book ),
22
+ ]);
23
+ } catch (TiteLiveBookNotFoundException $ e ) {
24
+ $ this ->delete ();
25
+ }
21
26
22
27
return $ this ;
23
28
}
You can’t perform that action at this time.
0 commit comments