laravel-nova-nested-form
laravel-nova-nested-form copied to clipboard
Global search is broken, when using NestedForm
I have a resource User
with a nested Form Posts
, just like the example in the documentation:
NestedForm::make('Posts', 'posts', \App\Nova\Post::class)
Now, the global search is broken, since the API (/nova-api/search?search=test) returns a 404 error instead of the json result. Commenting out the nested form and everything works as expected.
The relation itself work. When I add the HasMany field (and leave the NestedForm commented out), everything still works as expected:
HasMany::make("Posts", "posts", \App\Nova\Post::class),
i have the same issue. Did you manage to fix it or have a workaround?
Nope. I haven't fixed this issue yet.
The problem is in src/NestedForm.php:200 which got introduced in commit 0905cca77736cd7bdfcea6d86229af95e9f81945 . I'm not sure what it actually does, but latest Nova seems to work without it.
By adding a condition before src/NestedForm.php:200 line, the search is working again :
// Added this condition, so the error doesn't occur when the request is a GlobalSearchRequest
if(get_class(app(NovaRequest::class)) !== "Laravel\Nova\Http\Requests\GlobalSearchRequest")
$this->resolve(app(NovaRequest::class)->model());
Did a PR