vandyczech
5 months ago

LARAVEL 5.4 Create tree for data from collection

Posted 5 months ago by vandyczech

I have data in mysql and I need create tree wit level like cat , sub, sub sub ... sub sub sub ... and etc... but I dont know how, can u help me please? Of course optimalize for Laravel

Result what I want

Dir A
------  Doc 1
------  Doc 2
Dir B
Dir C
------  Doc 3
--------------- Dir E
Dir D

Mysql table

id  name    parent_id
------------------------
1   A       0
2   B       0
3   C       0   
4   Doc 1   1
5   D       0
6   Doc 2   1
7   Doc3    3
8   E       7

Please sign in or create an account to participate in this conversation.