W
W
WebDev2016-07-29 17:01:34
Laravel
WebDev, 2016-07-29 17:01:34

Nested with in laravel?

There is a table of tags, tags are nested in each other.
The tags, and tag_tag tables.
You need to get a nested tag tree.
I write like this:
$tags = Tag::with('tags')->get();
Now I display recursively the name of the tag and its child tags. I access child tags via $tag->tags
The fact is that nesting can be large, and the selection code selects child tags only for the first level.
For example:

Tag-1
    Tag-2
        Tag-3

With such nesting, I will receive only Tag-1 and Tag-2 with one request, and I will already receive Tag-3 with a separate request. Is it possible to somehow select all the nesting at once using Laravel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Pochepko, 2016-07-29
@kirill-93

By standard means - is not present.
But in the open spaces I came across this package. May help you
https://github.com/lazychaser/laravel-nestedset

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question