Skip to content

Commit 617af73

Browse files
Small fixes on HasBook(s)Attribute
1 parent 564fa31 commit 617af73

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"spatie/laravel-package-tools": "^1.14.0"
1616
},
1717
"require-dev": {
18+
"laravel/framework": "^10.48",
1819
"laravel/pint": "^1.0",
1920
"nunomaduro/collision": "^7.8",
2021
"orchestra/testbench": "^8.8|^9.0",

src/Utils/HasBookAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function book(): Attribute
2626
{
2727
return Attribute::make(
2828
get: fn () => $this->attributes['book'] ?? null
29-
? new Book($this->fromJson($this->attributes['book']))
29+
? new Book($this->fromJson($this->attributes['book'] ?? '{}'))
3030
: null
3131
);
3232
}

src/Utils/HasBooksAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function refreshBooks(bool $force = false): self
3434
public function books(): Attribute
3535
{
3636
return Attribute::make(
37-
get: fn () => collect($this->fromJson($this->attributes['book'] ?? []))
37+
get: fn () => collect($this->fromJson($this->attributes['books'] ?? '{}'))
3838
->whereNotNull()
3939
->map(fn ($attributes) => new Book($attributes))
4040
->values()

0 commit comments

Comments
 (0)