vendredi 1 novembre 2019

Creating sub lists with Laravel models

I am trying to create a todo application with Laravel, an example look is below

enter image description here

If I only had main level Lists I would have no problem. Also it the tasks were before or after the sub lists again I would have no issues.

Especially the order is Task 1, then two SubLists then Task22 bit is where I cannot think of a way to generate.

Currently I have List model and Task level. A list hasMany Task and a Task belongsTo a List. I tried to add a relation List hasMany List but cannot think of a good way to use the eager loading of ordered list items and their tasks like time image above.

I may end up writing raw queries but I wanted to get a idea from anyone with a better experience and understanding Laravel relations and models.

Thank you very much for any advice you share and hope this question helps someone who is failing to create a relation like this one.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire