问答详情
源自:2-3 Laravel-表单列表及分页实现

分页报错,$students 可以获取数据。没有分页前表单显示也没问题


操作:

public function index(){

$students = Student::paginate(3);

//echo "<pre>";

//var_dump($students);

return view('student.index',['student'=>$students]);

}



模板:

<div class = "pull-right" >  

{{ $student->render() }}

</div>

报错:

ErrorException in Builder.php line 2093:Call to undefined method Illuminate\Database\Query\Builder::render() (View: D:\phpStudy\WWW\lara5.1\resources\views\student\index.blade.php)


提问者:慕粉3413248 2016-12-30 22:44

个回答

  • 慕粉3413248
    2016-12-30 22:48:49

    解决了,在上面使用foreach的时候

    @foreach($student as $student)这样写竟然会跟下面$student产生冲突,在foreach时@foreach($student as $val)就没事了,,不懂背后原理。。。