Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependable MorphTo will not work correctly #62

Closed
preliot opened this issue Jun 17, 2019 · 7 comments
Closed

Dependable MorphTo will not work correctly #62

preliot opened this issue Jun 17, 2019 · 7 comments
Labels
bug Something isn't working confirmed This issue has been confirmed and reproduceable
Milestone

Comments

@preliot
Copy link

preliot commented Jun 17, 2019

When using a MorphTo Field in a Nova Dependency Container, it wil fail. You can select a Client or Department (see example), but then i can't select the specific Client or Department, because of an error.

 $fields[] = NovaDependencyContainer::make([
                     Fields\MorphTo::make('org_level')
                ->types([\App\Nova\OrgLevel\Client::class, \App\Nova\OrgLevel\Department:class]);
                ])->dependsOn('some_other_field', 'some_value');

\\Will result in this error
[2019-06-17 10:39:02] local.ERROR: Call to a member function buildMorphableQuery() on null {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function buildMorphableQuery() on null at <path-to-my-project>

This issue can be traced to:

Laravel\Nova\Http\Controllers\MorphableController.php > index method

$field = $request->newResource()
                        ->availableFields($request)
                        ->firstWhere('attribute', $request->field);

$field will be null and therefore the method will fail with the exception.

@notfalsedev
Copy link

Got the same issue.

@wize-wiz wize-wiz added bug Something isn't working confirmed This issue has been confirmed and reproduceable labels Sep 26, 2019
@wize-wiz wize-wiz added this to the v1.3 milestone Sep 26, 2019
@wize-wiz
Copy link
Contributor

@preliot @artisaninweb could one of you give me a short working example with models/resources on how you build the relationships?

@preliot
Copy link
Author

preliot commented Oct 9, 2019

Update: just updated to Nova 2.4.0 and not seeing it anymore. Not sure if the update fixed it or something i've done earlier. Saw a comment in my code, could be a hint:

//bugfix: field uses a morphTo, which adds required rule to org_level_type.

@wize-wiz
Copy link
Contributor

wize-wiz commented Oct 9, 2019

@preliot That's good to hear, you could close this issue if the problem is fixed and open a new issue if something pops up again somewhere else.

It could also have been fixed in the 1.2.x merge release.

@mira-thakkar
Copy link

@preliot i am facing this issue in nova 3.14 and package version 1.12.
Can you help me know how you fixed it?

@preliot
Copy link
Author

preliot commented Nov 6, 2020

@preliot i am facing this issue in nova 3.14 and package version 1.12.
Can you help me know how you fixed it?

Could you open a new issue and give some more details?

@mira-thakkar
Copy link

mira-thakkar commented Nov 6, 2020

@preliot Sure. Here i have created the issue for the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed This issue has been confirmed and reproduceable
Projects
None yet
Development

No branches or pull requests

4 participants