在 Laravel 5.5 中对评论和模型进行分页
Paginate Comments and Models in Laravel 5.5
我正在尝试对评论部分和 cadmodels 部分进行分页...但什么也没发生...请告诉我哪里错了。
这是分页代码..
public function index()
{
$user_id = Auth::user()->id;
$user = User::where('id',$user_id)->first();
$user->load('cadmodels','comments.cadmodel')->paginate(5);
$categories = Categories::all();
return view('dashboard.index',['user'=>$user,'categories'=>$categories]);
}
public function index()
{
$user_id = Auth::user()->id;
$user = User::where('id',$user_id)->first();
$user->load('cadmodels','comments.cadmodel');
$categories = Categories::all();
return view('dashboard.index',['user'=>$user->paginate(5),'categories'=>$categories]);
}
您需要在显示结果的视图上添加 {{ $whatever->links() }}。
我正在尝试对评论部分和 cadmodels 部分进行分页...但什么也没发生...请告诉我哪里错了。
这是分页代码..
public function index()
{
$user_id = Auth::user()->id;
$user = User::where('id',$user_id)->first();
$user->load('cadmodels','comments.cadmodel')->paginate(5);
$categories = Categories::all();
return view('dashboard.index',['user'=>$user,'categories'=>$categories]);
}
public function index()
{
$user_id = Auth::user()->id;
$user = User::where('id',$user_id)->first();
$user->load('cadmodels','comments.cadmodel');
$categories = Categories::all();
return view('dashboard.index',['user'=>$user->paginate(5),'categories'=>$categories]);
}
您需要在显示结果的视图上添加 {{ $whatever->links() }}。