mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.26k stars 215 forks source link

Fixes `query` attribute not existing under strict mode #465

Open daika7ana opened 5 months ago

daika7ana commented 5 months ago

When saving a model and Model::shouldBeStrict() is enabled, or to be more precise Model::preventAccessingMissingAttributes(), the $query attribute will not be accessible with the following error:

The attribute [query] either does not exist or was not retrieved for model [App\Models\ExampleModel].
{"userId":1,"exception":"[object] (Illuminate\\Database\\Eloquent\\MissingAttributeException(code: 0): 
The attribute [query] either does not exist or was not retrieved for model [App\\Models\\ExampleModel]. 
at /app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:475)

This PR should fix this issue without impacting any functionality. Will solve #437.

SkyLundy commented 4 months ago

Thanks for this fix. Solved the issue for me.

mikebronner commented 3 weeks ago

need to get tests to run and pass