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

Laravel 4.2 - Saving Models and moving them to existing parent resets values #191

Open inctor opened 9 years ago

inctor commented 9 years ago

Hey,

I noticed after a recent composer update, that when we create a model and saving it, and then move it to a parent, som of the values are being reset on the model.

In our case, the "name" attribute is set to empty.

We're using this;

  public function moveToNewParent(OrganizationalUnit $ou, OrganizationalUnit $parent)
  {
    $ou->makeChildOf($parent);
  }

When i look at the var_dump of the results, i notice this:

  ["attributes":protected]=>
  array(11) {
    ["id"]=>
    string(3) "848"
    ["name"]=>
    string(7) "fdasfds"
    ["code"]=>
    string(0) ""
    ["parent_id"]=>
    NULL
    ["lft"]=>
    string(3) "261"
    ["rgt"]=>
    string(3) "262"
    ["depth"]=>
    int(0)
    ["company_id"]=>
    string(1) "2"
    ["created_at"]=>
    string(19) "2015-10-20 07:33:26"
    ["updated_at"]=>
    string(19) "2015-10-20 07:33:26"
    ["deleted_at"]=>
    NULL
  }
  ["original":protected]=>
  array(11) {
    ["id"]=>
    string(3) "848"
    ["name"]=>
    string(0) ""
    ["code"]=>
    string(0) ""
    ["parent_id"]=>
    NULL
    ["lft"]=>
    string(3) "261"
    ["rgt"]=>
    string(3) "262"
    ["depth"]=>
    int(0)
    ["company_id"]=>
    string(1) "2"
    ["created_at"]=>
    string(19) "2015-10-20 07:33:26"
    ["updated_at"]=>
    string(19) "2015-10-20 07:33:26"
    ["deleted_at"]=>
    NULL
  }

As you can see, the "name" is being changed to being empty, for some reason. I've checked the input data all the way down to Node.php model where it's being changed for some reason?