yassilah / laravel-nova-nested-form

This package allows you to include your nested relationships' forms into a parent form.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global search is broken, when using NestedForm

bernhardh opened this issue · comments

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 0905cca . 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