laravel / nova-issues

557 stars 34 forks source link

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

Closed juse-less closed 2 years ago

juse-less commented 2 years ago

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](https://user-images.githubusercontent.com/76173223/195950604-8f92db03-4ac4-41aa-8763-90a4d67cfc17.png) https://user-images.githubusercontent.com/76173223/195950613-351961cd-6fa5-409b-95c6-edd6413d6735.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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

github-actions[bot] commented 2 years ago

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.