fix: unnecessary foreign key in Entity::$original#21
fix: unnecessary foreign key in Entity::$original#21
Entity::$original#21Conversation
neznaika0
left a comment
There was a problem hiding this comment.
See also HasRelations::getDataForRelationByIds(), HasRelations::getDataForRelationById().
example, students have cources.
protected attributes -> array (6) [ // <<<
'id' => string (1) "1"
'firstname' => string (3) "Joe"
'lastname' => string (5) "Smith"
'created_at' => string (19) "2025-10-07 16:43:54"
'updated_at' => string (19) "2025-10-07 16:43:54"
'courses' => array (3) [
0 => Tests\Support\Entities\Course#1178 (9) (
...
protected original -> array (5) [ // <<<
'id' => string (1) "1"
'firstname' => string (3) "Joe"
'lastname' => string (5) "Smith"
'created_at' => string (19) "2025-10-07 16:43:54"
'updated_at' => string (19) "2025-10-07 16:43:54"
]You also need to synchronize for `with()'. At least for find*, we get a new object simply by modifying it before using it.
While I was writing a comment... This may be a mistake for lazy loading.
Case:
- Requested objects without courses
- The student has been changed, there are no courses
- We lazily load courses and synchronized them along with the changes.
Seems like you just need to update the$original['cources']here?
|
Seems like a can of worms. Honestly, I never use |
|
I'll try to find a solution. Yes, I've also used Fix solves half of the problem. You can leave it as a temporary solution. |
Description
This PR fixes a bug where the entity is not fully synchronized.
Fixes #19
Checklist: