【发布时间】:2017-12-08 03:17:41
【问题描述】:
我在 php/laravel 中使用 foreach 访问以下值:
代码:
@foreach($users as $user)
{{$user}}
@endforeach
结果:
{
"id": 97,
"user_id": 68,
"reporting": "25",
"created_at": "2017-11-28 09:18:57",
"updated_at": "2017-11-28 09:18:57",
"reporting_users": [
{
"id": 2,
"attendanceId": 1,
"name": 68,
"attendanceDate": "2017-12-04 00:00:00",
"clockIn": "2017-12-04 05:10:00",
"clockOut": "2017-12-04 05:10:00",
"workTime": "2017-12-04 05:10:00",
"reason": "test",
"status": 1,
"created_at": null,
"updated_at": null
}
],
"find_user": {
"id": 68,
"attendances_id": 1,
"name": "Ahsan Khyraj",
"email": "ahsan22@gmail.com",
"verificationToken": "nhpyzVQr8YjFJbHvokrzjwee2",
"status": 1,
"userType": 1,
"department": 1,
"created_at": "2017-11-28 09:18:57",
"updated_at": "2017-11-28 09:18:57"
}
}
现在如何访问值 attendanceId 和 email ?
我能够获得报告的价值
{{$user->reporting}}
但是我如何访问 reporting_users 和 find_user 中的其他值
【问题讨论】: