class HomeController extends Controller
{
function one_one(){
$data=Student::all();
return view('welcome',compact('data'));
}
}
在视图中
@foreach($data as $std_marks)
<tr>
<td>{{$std_marks->std_id}}</td>
<td>{{$std_marks->marks['java']}}</td>
<td>{{$std_marks->marks['cprog']}}</td>
<td>{{$std_marks->marks['csharp']}}</td>
<td>{{$std_marks->marks['sqldb']}}</td> <--this is working
<td>{{$std_marks->marks->sqldb}}</td> <--- here is the problem
</tr>
@endforeach
当我打印$std_marks->marks
时,它会显示所有属性,但是当我按照上面的方式打印时显示异常