lazychaser / laravel-nestedset

Effective tree structures in Laravel 4-8
3.66k stars 472 forks source link

Collection - newCollection() #236

Open otr-tomek opened 7 years ago

otr-tomek commented 7 years ago

It's great that You use trait instead of main model class extends.

Is there other way to use own/custom Collection than extending: MyCollection extends Kalnoy\Nestedset\Collection as Collection and overwriting newCollection() function?

By the way - when You set 'parent_id' to zero '0' (I had a bug in my view in option/dropdown list) - after save, tree position is updated too.

derpoho commented 7 years ago

Did you find a solution @otr-tomek ? Searching for the same!

lagunawebdesign commented 7 years ago

Nah. In model I use with trait, I had to create:

public function newCollection(array $models = array())
    {
        return new Extensions\AppCollection($models);
    }

You can overwrite (or copy) functions from Kalnoy\Nestedset\NodeTrait. Like: getLftName(), getRgtName(), boot() functions

derpoho commented 7 years ago

Pfah. Thats kind of counter-productive ;)