我有情况了。我有产品在愿望列表和我有行动:“删除”与ajax。
我有页码:
$wishlists = Wishlist::with('product')->where('user_id', $profile->id)
->orderby('id', 'desc')->paginate(3);最初,我有2页关于分页。
当我从愿望列表中删除项目时,在分页中我有1页,但是在页面上我有2页关于分页,因为我使用ajax。我如何检查,如果用户在页面上移动,它不存在分页和重定向他在第一页分页?
发布于 2018-02-10 08:33:58
查询前,您可以检查总页。
$totalRecords = Wishlist::with('product')->where('user_id', $profile->id)
->count();
$totalPage = $totalRecords/10; (where 10 is records per page)现在你检查一下
$ajaxpage = 3;
if($totalPage < $ajaxpage){
$ajaxpage = 1;(get last page)
}
$wishlists = Wishlist::with('product')->where('user_id', $profile->id)
->orderby('id', 'desc')->paginate($ajaxpage);https://stackoverflow.com/questions/48718617
复制相似问题