我正在使用成绩簿软件,我在显示成绩时遇到了一些问题。
我在视图文件中输入了以下行:
<p>{{!! $gradesArray = $user->grades !!}}</p>
但结果我得到了json格式的整个数组:
{[{"id":"10","grade":"1.3","user_id":"6","course_id":"3","created_at":"2016-01-08 16:31:14","updated_at":"2016-01-08 16:31:14","deleted_at":null},{"id":"11","grade":"1.7","user_id":"6","course_id":"2","created_at":"2016-01-08 22:59:43","updated_at":"2016-01-08 22:59:43","deleted_at":null},{"id":"12","grade":"2.0","user_id":"6","course_id":"1","created_at":"2016-01-09 13:26:09","updated_at":"2016-01-09 13:26:09","deleted_at":null}]}
我只能显示成绩和课程?
答案 0 :(得分:1)
@foreach($user->grades as $grade)
{{ $grade->grade }}
@endforeach