Samir Chahine Samir Chahine - 8 days ago 4x
PHP Question

How to print the subtasks belonging to specific tasks in Laravel Blade

This is really difficult for me to wrap my head around, so please excuse me if I don't give a good enough explanation of the situation.

I have a table "tasks", and the only column that I'm really using for this problem is

| tasks_id |

I created another table "subtasks", and it has these relevant columns:

| subtasks_id | subtasks_title | subtasks_tasks_id |

For each row in the table "tasks", there are
rows of subtasks with a different
but the same

I print the
by passing them to an array in my HomeController and looping through the array in the blade template. For every TASK, how would I also loop every SUBTASK, which has the same
and the tasks'

Is there a way to use the
clause in the blade template? I'm quite new to Laravel, also I didn't know how to word this into a google search so please do forgive my ignorance. Thank you in advanced.

P.S. I will keep on trying to solve this unless someone gives me an answer beforehand, if I do solve it I will post my answer, if not, please don't hesitate trying to help me :P, thank you again.


So I figured out what I had to do...

Using a multidimensional array, I can set the key to array $subtasks the | tasks_id | of any existing subtasks, then the value of each will be a corresponding array where the subtasks_tasks_id is the same as the key of the value. I then loop through each subtask by doing something like $subtask[$tasks_id][$i] where I create two outer loops (one is already created, so it shouldn't be too difficult). And now I know what to do, next step is the how, or really the actual coding, okay, that is all..