试图获得Laravel中非对象的属性,即使它具有属性

时间:2016-09-09 13:39:14

标签: laravel

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时,它会显示所有属性,但是当我按照上面的方式打印时显示异常

0 个答案:

没有答案