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

Laravel Model 'strict modes' cause all pages to fail to load (at least Resource, Lens) #4923

Closed
juse-less opened this issue Oct 14, 2022 · 4 comments
Assignees
Labels
bug Verified bug by the Nova team

Comments

@juse-less
Copy link

juse-less commented Oct 14, 2022

Description:

Apologies in advance. I'm not sure if this should be considered a bug, or a feature request to use that Laravel feature.

When using Laravel's newer Model::shouldBeStrict(), pages fail to load as Laravel is throwing exceptions.
More specifically it appears to be Model::preventAccessingMissingAttributes() that is throwing a fit.

The error thrown is

The attribute [pivot] either does not exist or was not retrieved for model [<Model FQN>].

The Model in question (User), in the provided repo, has no relationships.

Attached video and screenshot of the issue

ScreenShot 2022-10-14 at 22 27 43

ScreenShot.2022-10-14.at.22.27.26.mp4

Detailed steps to reproduce the issue on a fresh Nova installation:

  1. Check out the repo provided, using the branch issue/laravel-model-strictness
  2. Install dependencies, and publish assets
  3. Create a user
  4. Log in to Nova
  5. View any page (like the users resource)
@crynobone crynobone added the bug Verified bug by the Nova team label Oct 15, 2022
@crynobone crynobone self-assigned this Oct 15, 2022
@crynobone crynobone reopened this Oct 18, 2022
@crynobone
Copy link
Member

After various tests/changes to Nova, it seems impossible to support Model::preventAccessingMissingAttributes() without introducing breaking changes. As a result, I have submitted laravel/framework#44627 where you should be able to disable strict mode when accessed in Nova.

@juse-less
Copy link
Author

I had a hunch that was the case. In the meantime I've enabled all 3 separately, with Model::preventAccessingMissingAttributes() checking for the Nova routes as well. 👍

Thank you for putting time into this. 🙂

@crynobone
Copy link
Member

In the next release, Nova will automatically toggle Model::preventAccessingMissingAttributes() when handling Nova Requests.

@github-actions
Copy link

github-actions bot commented Nov 6, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team
Projects
None yet
Development

No branches or pull requests

2 participants