我正在尝试获取用户状态为老师(这是我的表中的字段)的所有结果。
当我尝试使用分页时,会遇到错误。
这是我在控制器中获取结果的代码:
public function index()
{
$status = User::where('status', '=', 'teacher')->get();
return view('Profile.alluser')->with('status', $status)->paginate(3);
}
*注意laravel版本为5.8
您需要对查询进行分页,而尝试对视图进行分页,请尝试以下代码:
public function index()
{
$status = User::where('status', '=', 'teacher')->paginate(3);
return view('Profile.alluser')->with('status', $status);
}