I have a simple Category-Table with (ID, Title, parent) if it's a root category the parent is 0. Now I want to build a category tree with a dash (-) for each level like this:
There are two common ways of storing hierarchical data in a relational database.
The first an the one you are currently using is called an adjacency list. Here you store the id of the parent node in each record. With this method you need to rebuild the tree each time you need to use it which generally involve recursion and can be slow for larger trees. Caching is a must which also adds the complexity of cache invalidation.
The second method is called a nested set which is a bit more complex. I don't really know how to describe this method without diagrams so I'll just link to a good article that explains it.
The major benefit here is building the tree is much easier and faster. The downside is that adding, removing, or deleting a node requires rebuilding part of the tree and updating all the affected nodes.
There are two popular packages in laravel to allow for nested set eloquent models. Both are good and it really doesn't matter which one you use.