2
votes

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 ..

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'));
}

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

2
What does "doesn't work" mean?Chris
Thanks for your answer Chris,, 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 ..MohcinBN

2 Answers

2
votes

This is because you are overwriting your $questions variable

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

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

0
votes

Add this to your view:

{!! $questions->render() !!}

If you want to paginate the links you should do something like this:

$links = $questions->links()->paginate();

And in the view add:

{!! $links->render() !!}