etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 460 forks source link

Fixed bug in postSave logic that was wiping out relations before push() #243

Open jcwatson11 opened 8 years ago

jcwatson11 commented 8 years ago

During the "saved" event, the reload() method is called, which, in turn calls getFreshInstance() and wipes out all relations that were on the model before save.

This breaks laravel's $model->push() method because it removes any relations that could be recursively saved.

Our use case involves a Hierarchical reference list that also carries translations as a relation. When we call push() all translations are wiped out because Baum loaded a fresh instance and tried to replace its relations with the empty set from the new model instance.

This pull request fixes that issue.

jcwatson11 commented 8 years ago

It appears that unit tests are failing in the master branch. As far as I can tell, the tests that are failing have nothing to do with this PR.