试图获得非对象Laravel 5的属性

时间:2015-08-19 10:24:49

标签: laravel-5.1

我正在尝试使用此查询从我的数据库表中检索数据:$features = DB::table('features')->get();然后我想在我的视图中使用它:

@foreach ($features as $feature)
                <tr>
                    <td>{{ $feature->id }}</td>
                    <td>{{ $feature->title }}</td>
                    <td>{{ $feature->description }}</td>
                    <td><a href="{{route('adminfeatures.edit',$features->id)}}" class="btn btn-warning">Update</a>
                    </td>
                    <td>
                        {!! Form::open(['method' => 'DELETE', 'route'=>['adminfeatures.destroy', $features->id]]) !!}
                        {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
                        {!! Form::close() !!}
                    </td>
                </tr>
            @endforeach

我收到此错误:Trying to get property of non-object 我试图返回$ feature而不是空。

我在这里想念的是什么?

1 个答案:

答案 0 :(得分:0)

此行中存在拼写错误

{!! Form::open(['method' => 'DELETE', 'route'=>['adminfeatures.destroy', $features->id]]) !!}

ID请求应该是$ feature而不是$ feature s