分頁報錯,$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)
2016-12-30
解決了,在上面使用foreach的時候
@foreach($student as $student)這樣寫竟然會跟下面$student產生沖突,在foreach時@foreach($student as $val)就沒事了,,不懂背后原理。。。