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

Saving not working with eloquent strict mode #437

Open
jamesRUS52 opened this issue Nov 18, 2022 · 3 comments
Open

Saving not working with eloquent strict mode #437

jamesRUS52 opened this issue Nov 18, 2022 · 3 comments
Assignees

Comments

@jamesRUS52
Copy link
Contributor

When using in app service provider

Model::shouldBeStrict(!$this->app->isProduction());

saving model not working with exception
Illuminate \ Database \ Eloquent \ MissingAttributeException
The attribute [query] either does not exist or was not retrieved for model [app\Models\MyModel].

Eloquent Query
Please provide the complete eloquent query that caused the bug, for example:

$record = MyModel::find($id);
$record->field = 'foo';
$record->save();

Stack Trace
Illuminate \ Database \ Eloquent \ MissingAttributeException
The attribute [query] either does not exist or was not retrieved for model [app\Models\MyModel].

Environment
PHP 8.1.6
Laravel 9.36.3
Model Caching: 0.12.5

** work around **
add to model

protected $query = null; // required property for Cachable trait

I think you should add this in trait

@jamesRUS52
Copy link
Contributor Author

up

@webard
Copy link

webard commented Feb 23, 2024

Bump, error is present with newest wersion of laravel and this package.

@Adesin-fr
Copy link

Also facing this !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants