我的 laravel 5.3 网站收到 JSON 格式的响应:
{#356 ▼
+"eventsreport": {#355 ▼
+"employ": array:6 [▼
0 => {#329 ▼
+"@id_staff_external": ""
+"@id_staff_internal": "6655"
+"@tab_n": ""
+"@fio": "Иванов Иван Иваныч"
+"@appoint_id_external": ""
+"@subdiv_id_external": ""
+"@appoint_id_internal": "5094"
+"@subdiv_id_internal": "6652"
+"@appoint_name": "Учащийся"
+"@subdiv_name": "5 Б класс"
+"events": array:8 [▼
0 => {#327 ▼
+"@id_staff_external": ""
+"@id_staff_internal": "6655"
+"@datetimeevent": "27.04.2017 9:05:05 PM"
+"@typepass": "Выход"
}
1 => {#313 ▶}
2 => {#323 ▶}
3 => {#317 ▶}
4 => {#316 ▶}
5 => {#314 ▶}
6 => {#328 ▶}
7 => {#321 ▶}
]
}
1 => {#330 ▼
+"@id_staff_external": ""
+"@id_staff_internal": "6642"
+"@tab_n": ""
+"@fio": "Ивановбаа Иван1баа Иваныч1баа"
+"@appoint_id_external": ""
+"@subdiv_id_external": ""
+"@appoint_id_internal": "6644"
+"@subdiv_id_internal": "5089"
+"@appoint_name": "Учащиеся"
+"@subdiv_name": "5 А класс"
}
2 => {#331 ▼
+"@id_staff_external": ""
+"@id_staff_internal": "6658"
+"@tab_n": ""
+"@fio": "Петров Петр Петрович"
+"@appoint_id_external": ""
+"@subdiv_id_external": ""
+"@appoint_id_internal": "5094"
+"@subdiv_id_internal": "6652"
+"@appoint_name": "Учащийся"
+"@subdiv_name": "5 Б класс"
+"events": array:6 [▶]
}
3 => {#338 ▶}
4 => {#339 ▶}
5 => {#354 ▶}
]
}
}
我想要实现的是按照以下格式在刀片表中显示这些数据:
fio|appoint_name|subdiv_name|datetimeevent|typepass
如您所见,任何employs
. 我的控制器有这段代码:
$client = new Client([
'base_uri'=> config('app.schools.'.$school_id).$rep_name,
'query' => ['dFrom'=>$dfrom,
'dTo'=>$dto,
'depId'=>$dep_id_perco
],
'timeout' => 10.0
]);
$response = $client->request('GET');
$results = json_decode($response->getbody()->getcontents());
$collection = new Collection($results);
我知道现在我可以传递$collection
我的观点了。但是我应该如何遍历employ
我$collection
的每个刀片?