Skip to content

Commit 5871659

Browse files
authored
Add support for Inertia optional props (#33)
1 parent 0555df5 commit 5871659

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/DataProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Contracts\Support\Jsonable;
1111
use Inertia\DeferProp;
1212
use Inertia\LazyProp;
13+
use Inertia\OptionalProp;
1314
use Inertia\Response;
1415
use ReflectionClass;
1516
use ReflectionMethod;
@@ -42,7 +43,7 @@ public function toArray(): array
4243
->filter(fn (ReflectionMethod $method) => ! $method->isStatic() && ! in_array($method->name, $this->excludedMethods))
4344
->mapWithKeys(function (ReflectionMethod $method) {
4445
$returnType = $method->getReturnType();
45-
if ($returnType instanceof ReflectionNamedType && in_array($returnType->getName(), [DeferProp::class, LazyProp::class, Closure::class])) {
46+
if ($returnType instanceof ReflectionNamedType && in_array($returnType->getName(), [DeferProp::class, LazyProp::class, OptionalProp::class, Closure::class])) {
4647
return [$method->name => $method->invoke($this)];
4748
}
4849

0 commit comments

Comments
 (0)