Skip to content

Commit b7b9adb

Browse files
committed
FIX closure serialization
1 parent e914c1c commit b7b9adb

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to `laravel-inertia-dataproviders` will be documented in this file.
44

5+
## v1.6.2 - 2024-09-20
6+
7+
* Closure serialization bugfix.
8+
9+
**Full Changelog**: https://github.com/webfox/laravel-inertia-dataproviders/compare/v1.6.1...v1.6.2
10+
511
## v1.6.1 - 2024-06-21
612

713
* Attribute name formatting bugfix.

src/DataProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Webfox\InertiaDataProviders;
66

7+
use Closure;
78
use Illuminate\Contracts\Support\Arrayable;
89
use Illuminate\Contracts\Support\Jsonable;
910
use Inertia\LazyProp;
@@ -41,7 +42,7 @@ public function toArray(): array
4142
->filter(fn (ReflectionMethod $method) => ! $method->isStatic() && ! in_array($method->name, $this->excludedMethods))
4243
->mapWithKeys(function (ReflectionMethod $method) {
4344
$returnType = $method->getReturnType();
44-
if ($returnType instanceof ReflectionNamedType && $returnType->getName() === LazyProp::class) {
45+
if ($returnType instanceof ReflectionNamedType && in_array($returnType->getName(), [LazyProp::class, Closure::class])) {
4546
return [$method->name => $method->invoke($this)];
4647
}
4748

0 commit comments

Comments
 (0)