Laravel中的分页不起作用 [英] Pagination in Laravel doesn't work

查看:72
本文介绍了Laravel中的分页不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我发表自己的观点时,{!!$questions->links();!!}我看不到分页样式,该页面也不像我放在控制器中那样每页花费6个帖子..

When i put in my view {!! $questions->links(); !!} i don't see the pagination style and the page dont take 6 post per page like i put in my controller ..

我的帖子控制器:class QuestionsController扩展了控制器{

My post Controller : class QuestionsController extends Controller {

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function index()
{


       $questions = \App\Question::latest()->paginate(6);
               $questions = \App\Question::unsolved();
               $bars     = \App\Question::unsolvedbar();
               $links = str_replace('/?', '?', $questions->render());
       return view('questions.index',compact('questions','bars','links'));
}

我的视图中的我的分页链接:{!!$ questions-> links();!!}

My Pagination Links in my View: {!! $questions->links(); !!}

推荐答案

这是因为您正在覆盖$ questions变量

This is because you are overwriting your $questions variable

$questions = \App\Question::latest()->paginate(6);
$questions = \App\Question::unsolved();

在没有unsolved()函数声明的情况下,Cant确实可以告诉您更多信息.

Cant really tell you more without the unsolved() function declaration.

这篇关于Laravel中的分页不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆