Closed Ahrengot closed 2 years ago
I don't think I will be able to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)
The only thing I can think of why this is happening is that your Landing
resource doesn't have an ID
field. But as mentioned earlier we would need a full reproducing repository to verify as there isn't enough information to verify the issue. We do have enough feature tests for ID
field
Thank you for for your help @crynobone
You're right! It was the missing id. If I remove this line: https://github.com/Ahrengot/morphone-nova-example/blob/master/app/Nova/LandingPage.php#L44 then the error appears.
Guess I'm never removing an ID column from a nova resource again 😀
If possible retain the ID field as it made resolving the key for a resource will require fewer steps. But it is clear now where it can cause errors and how we can fix/improve this.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Description:
I have two models connected via a polymorphic relationship and I get a loading error if I load up a tenant in Nova that doesn't yet have a landing page. If I remove
->withDefault()
from the relationship definition the error disappears.Table structure
tenants
landing_pages
Eloquent relationships
in
App\Models\Tenant.php
in
App\Models\LandingPage.php
Nova resources
in
App\Nova\Tenant.php
in
App\Nova\LandingPage.php
Detailed steps to reproduce the issue on a fresh Nova installation:
withDefault()
chained after the relationship.->withDefault()
method is triggered.Attempt to read property "nullable" on null
inLaravel\Nova\Fields\ID:forResource