baum icon indicating copy to clipboard operation
baum copied to clipboard

Load nested set by default in Laravel Relation definition

Open JoshuaDoshua opened this issue 9 years ago • 1 comments

Thanks so much for taking this project over!!

Is there a way to eager load a nested relationship using Laravel's relationship definitions instead of calling ->toHierarchy()?

i.e.

class Post extends Model
{
    public function categories()
    {
        return $this->hasManyRootsWithDescendants(Category::class);
    }
}

to return a nested set of categories

If this is a feature request I'd be glad to take a look Or is there a better way to load a nested set by default?

JoshuaDoshua avatar May 23 '16 03:05 JoshuaDoshua

I like this idea but I envisage it being a fair bit of work. Happy for someone to look in to it, or I'll take a look if (when) I get time.

gazsp avatar Feb 08 '17 22:02 gazsp