Skip to content

Commit b8a8405

Browse files
authored
Merge pull request #22 from webfox/fix-close-handling
FIX closure serialization
2 parents e914c1c + c8e8112 commit b8a8405

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

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

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

5+
## v2.0.0 - 2024-09-20
6+
7+
* Closure serialization bugfix.
8+
* Drop support for Laravel 9, 10
9+
10+
**Full Changelog**: https://github.com/webfox/laravel-inertia-dataproviders/compare/v1.6.1...v1.6.2
11+
512
## v1.6.1 - 2024-06-21
613

714
* Attribute name formatting bugfix.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"inertiajs/inertia-laravel": "Needed for basic inertia functionality"
2020
},
2121
"require": {
22-
"php": "^8.1",
22+
"php": "^8.2",
2323
"spatie/laravel-package-tools": "^1.14.0",
24-
"illuminate/contracts": "^9.0|^10.0|^11.0"
24+
"illuminate/contracts": "^11.0"
2525
},
2626
"require-dev": {
2727
"inertiajs/inertia-laravel": "<2",

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)