{"action":"created","issue":{"url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/90","repository_url":"https://api.github.com/repos/lazychaser/laravel-nestedset","labels_url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/90/comments","events_url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/90/events","html_url":"https://github.com/lazychaser/laravel-nestedset/issues/90","id":138666744,"number":90,"title":"Creating Node model in observer fails","user":{"login":"Propaganistas","id":6680176,"avatar_url":"https://avatars.githubusercontent.com/u/6680176?v=3","gravatar_id":"","url":"https://api.github.com/users/Propaganistas","html_url":"https://github.com/Propaganistas","followers_url":"https://api.github.com/users/Propaganistas/followers","following_url":"https://api.github.com/users/Propaganistas/following{/other_user}","gists_url":"https://api.github.com/users/Propaganistas/gists{/gist_id}","starred_url":"https://api.github.com/users/Propaganistas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Propaganistas/subscriptions","organizations_url":"https://api.github.com/users/Propaganistas/orgs","repos_url":"https://api.github.com/users/Propaganistas/repos","events_url":"https://api.github.com/users/Propaganistas/events{/privacy}","received_events_url":"https://api.github.com/users/Propaganistas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2016-03-05T10:17:03Z","updated_at":"2016-03-07T19:54:13Z","closed_at":null,"body":"Hi\r\n\r\nSuppose the following setup where a node model is being created as a consequence of the creation of `ModelA`:\r\n\r\n```php\r\nclass NodeModel extends Model\r\n{\r\n    use NodeTrait;\r\n}\r\n\r\nclass ModelA extends Model {\r\n\r\n    protected static function boot()\r\n    {\r\n        parent::boot();\r\n\r\n        static::created(function ($model) {\r\n            NodeModel::create([]);\r\n        });\r\n    }\r\n}\r\n```\r\n\r\nUnfortunately this doesn't work. On `dd`'ing the `NodeModel::create` line a model is effectively returned with `$exists` set to true, but it simply isn't persisted to the database.\r\nUpon removing the `NodeTrait` the setup *does* work and the NodeModel can be found in the database as expected.\r\n\r\nCan someone replicate this?"},"comment":{"url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/comments/193422025","html_url":"https://github.com/lazychaser/laravel-nestedset/issues/90#issuecomment-193422025","issue_url":"https://api.github.com/repos/lazychaser/laravel-nestedset/issues/90","id":193422025,"user":{"login":"Propaganistas","id":6680176,"avatar_url":"https://avatars.githubusercontent.com/u/6680176?v=3","gravatar_id":"","url":"https://api.github.com/users/Propaganistas","html_url":"https://github.com/Propaganistas","followers_url":"https://api.github.com/users/Propaganistas/followers","following_url":"https://api.github.com/users/Propaganistas/following{/other_user}","gists_url":"https://api.github.com/users/Propaganistas/gists{/gist_id}","starred_url":"https://api.github.com/users/Propaganistas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Propaganistas/subscriptions","organizations_url":"https://api.github.com/users/Propaganistas/orgs","repos_url":"https://api.github.com/users/Propaganistas/repos","events_url":"https://api.github.com/users/Propaganistas/events{/privacy}","received_events_url":"https://api.github.com/users/Propaganistas/received_events","type":"User","site_admin":false},"created_at":"2016-03-07T19:54:12Z","updated_at":"2016-03-07T19:54:12Z","body":"```php\r\nclass BaseModel extends Model\r\n{\r\n   public static function boot() {\r\n      parent::boot();\r\n\r\n      // static::saving(function(){....});  --> I've commented this out\r\n}\r\n\r\nclass MenuItem extends BaseModel\r\n{\r\n   use NodeTrait;\r\n}\r\n```"}}