【发布时间】:2017-08-30 05:46:57
【问题描述】:
这是控制器功能。我需要为此设置分页。
public function student_list(){
$students = Student::orderBy('first_name')->get();
$stu_na = "Test Page";
return view('student/student_list', compact('stu_na', 'students'));
}
阅读文档后,我尝试了以下方法。
第一种方式: $students = Student::orderBy('first_name')->get()->paginate(5);
错误:方法分页不存在。
第二种方式:$students = Student::orderBy('first_name')->paginate(5)->get();
错误:类型错误:函数参数太少 Illuminate\Support\Collection::get()
我应该如何在我的控制器中使用分页?
【问题讨论】:
标签: php laravel laravel-5 pagination laravel-pagination