2

I am getting Data using Eloquent by the following way and with pageinate

$BlogData = BlogModel::paginate(2);

I am getting 2 coloumn in the target page but i don't know how to display the pagination in the view.

I tried to display

{{ $paginator->getUrl($paginator->getCurrentPage()+1) }}

{{$paginator->links();}}

But it throws error Undefined variable: paginator (View: C:\xampp\htdocs\app\views\Blo

enter image description here

How can i do that

Anthony
  • 36,459
  • 25
  • 97
  • 163
Biz Dev B
  • 383
  • 1
  • 6
  • 18

1 Answers1

1

If you are passing the $blogData to the view, you just need to use {{$blogData->links}} in the blade template. Is very clear how to use it in the official docs: http://laravel.com/docs/4.2/pagination

Tomas Ramirez Sarduy
  • 17,294
  • 8
  • 69
  • 85
  • I tried the same , but i didn't got it , Even the code was inside the foreach – Biz Dev B Dec 25 '14 at 16:20
  • @BizDevB u dont add the {{ $blogData->links() }} inside the loop ,u put it out side like a normal div , also {{$paginator->links();}} will give error because of the `;` – ctf0 Dec 25 '14 at 16:31
  • It came awesome **http://localhost/blog?page=2** Can i change it like **blog/2** like this – Biz Dev B Dec 25 '14 at 16:34
  • i believe not ,u can add more strings to it ,make the pagination button go to somewhere else but no u cant remove the `page=` part. – ctf0 Dec 25 '14 at 16:38
  • @BizDevB: The paginate need to be outside the foreach loop, and you can make some tricks hack the urls [like this](http://stackoverflow.com/questions/21305857/laravel-pagination-redirect) – Tomas Ramirez Sarduy Dec 25 '14 at 17:45