-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Note: Testing with v1.0.0-beta.2 to put off migration work however as far as I am aware this issue is not changed on subsequent releases up to beta.5 per the release notes.
In my case, I have Eloquent saving / creating / updating events which are performing a correctness check in a case with a somewhat complex parent/child hierarchy which is tracked with a "parent_id" ID number attribute on the models. The events are performing a consistency check, and rather than throwing a bunch of errors for no reason and to allow a hierarchy change with only one API event, I am checking and making a bunch of changes to multiple models to resolve what would otherwise be a hierarchy conflict. Sometimes this involves editing the model which itself is updated via the API call before saving.
When this occurs (server-side automatic edits to models which are both the subject of the API call as well as some related models via the Eloquent saving / updating / creating events), and the response is commanded to include some related models for example, the server-side changes which are applied to the root model are not reflected in the response however the changes made to all other models are reflected in the "include" response. I can confirm that Laravel itself is applying the changes and committing them to the database but the API response does not reflect that. It's as though the API has buffered the Eloquent object before the saving/updating/creating event and does not reflect changes, however it probably is newly querying for "include" resources and so those changes are reflected.
I get that directly editing attributes on the saving/updating/creating method parameters is not exactly kosher but it works and Laravel accepts it so I figure so should the API response for consistency reasons.
Environment:
- PHP 7.1
- Laravel 5.5
- laravel-json-api v1.0.0-beta.2