I have API data which I get from controller using
return parent::with('children')->get();
it gives me this:
[
{
"id":1,
"name":"George",
"children":[
{
"id":4,
"parent_id":"1",
"name":"Glory"
},
{
"id":5,
"parent_id":"1",
"name":"Susan"
}
]
},
{
"id":2,
"name":"Robin",
"children":[
{
"id":9,
"parent_id":"2",
"name":"Luke"
}
]
}
]
I can display it after fetching with axios like this:
George has 2 children:
1. Glory
2. Susan
Robin has 1 child:
1. Luke
Now my goal is to display it like this:
Name | parent's name
~~~~~~~~~~~~~~~~~~~~~~~
Glory | George
Susan | George
Luke | Robin
is there a way to achieve it in vue js or in contoller, models or anyewhere else?