laravel 未定义的属性:Illuminate\Pagination\LengthAwarePaginator::$name
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38475845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Undefined property: Illuminate\Pagination\LengthAwarePaginator::$name
提问by Gvep
I am trying to get data from my table and show it in my view and paginate this data. I received this problem and couldn2t find any solution. I did the exactly same thing in my previous project and it worked well.
我正在尝试从我的表中获取数据并将其显示在我的视图中并对这些数据进行分页。我收到了这个问题,但找不到任何解决方案。我在之前的项目中做了完全相同的事情,而且效果很好。
here is my Controller
这是我的控制器
public function hadiBirlikteCalisalimShow (){
$users =DB::table('birlikte_calisalim')->paginate(15);
return view('admin.birliktecalisalim',compact(['users']));
}
and this is my view
这是我的观点
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>?sim</th>
<th>Email</th>
<th>Tarih</th>
<th>?stek</th>
</tr>
</thead>
<tbody>
@foreach($users as $row)
<tr>
<td>{{$users->name}}</td>
<td>{{$users->email}}</td>
<td>{{$users->tarih}}</td>
<td>{{$users->message}}</td>
</tr>
@endforeach
</tbody>
</table>
{{$users->links()}}
采纳答案by Raymond Cheng
@foreach($users as $row)
<tr>
<td>{{$row->name}}</td>
<td>{{$row->email}}</td>
<td>{{$row->tarih}}</td>
<td>{{$row->message}}</td>
</tr>
@endforeach
should be $row->name,$row->email
, etc... not $users->name
, and change {{$users->links()}}
to {!! $users->render() !!}
应该是$row->name,$row->email
,等等...不是$users->name
,并更改{{$users->links()}}
为{!! $users->render() !!}