below is the Json returned from controller to view
JSon Data
[
{
"id":2,
"firstname":"Beth",
"lastname":"Hanley",
"email":"bah3@hw.ac.uk",
"role":1,
"university":1,
"school_dept":5,
"year":2,
"photo":"URL",
"bio":"ObxBJIDO6IfOU0DIw8a5",
"search_status":"available",
"created_at":null,
"updated_at":null,
"languages":[
{
"id":3,
"language":"Spanish",
"pivot":{
"user_id":2,
"language_id":3,
"type":"native"
}
},
{
"id":4,
"language":"Greek",
"pivot":{
"user_id":2,
"language_id":4,
"type":"learn"
}
}
],
"hobbies":[
{
"id":2,
"hobby":"Basketball",
"pivot":{
"user_id":2,
"hobbie_id":2
}
},
{
"id":3,
"hobby":"Skiing",
"pivot":{
"user_id":2,
"hobbie_id":3
}
},
{
"id":4,
"hobby":"Running",
"pivot":{
"user_id":2,
"hobbie_id":4
}
}
],
"universities":{
"id":1,
"university":"Heriot-Watt"
},
"years":{
"id":2,
"year":"2nd"
},
"departments":{
"id":5,
"department":"Languages and Intercultural Studies"
}
}
]
I am able to pull id, firstname,lastname, email, ... first level data
@foreach($users as $user)
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
</tr>
@endforeach
Also, departments, university and years second level nested data
<td> </td>
<td> </td>
<td> </td>
<td> </td>
But how to pull third level nested data plus its a type of array.
for example: Hobbies and Languages both.
I want to show languages like: learn : English and teach: French this has to be achieved by checking if type field is learn or teach in language array with a field called type. which tells if a user wants to learn a specific language or teach that language. All users have learn and teach both types.
Also, for list of hobbies like: hobby1, hobby2, hobby3,...
I want to show this most neatest and efficient way possible
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lhvMYz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire