xalaida/laravel-tree

Path is not being set.

rojermaharjan opened this issue · 1 comments

I seeded in some user data and associated some users to others. User model has the trait implemented.

$currentUser->parent()->associate($currentManager);
$currentUser->save();

The path column in the database is NULL. When querying ancestors and descendants, I'm getting error saying getPath() must return a Path object and null is being returned.

Edit:
It was caused by WithoutModelEvents trait in the seeder class. Since, this package updates the path on created and creating events, they were not being set.

Yes, you are correct, we need events to be on.