Skip to content

Commit ae886f7

Browse files
committed
Add support for Inertia optional props
1 parent 4378862 commit ae886f7

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
@@ -9,6 +9,7 @@
99
use Illuminate\Contracts\Support\Jsonable;
1010
use Inertia\DeferProp;
1111
use Inertia\LazyProp;
12+
use Inertia\OptionalProp;
1213
use Inertia\Response;
1314
use ReflectionClass;
1415
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)