Support the ongoing development of Laravel.io →
posted 9 years ago
Validation
Last updated 2 years ago.
0

Can you elaborate a bit more on what you are trying to do?

http://laravel.com/docs/5.1/pagination#manually-creating-a-paginator

0

Thank you elite123, I have my own Html Template for Pagination,

 <div class="page_numbers">
                <ul class="pagination">
                    <li class="onpage"><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li>...</li>
                    <li><a href="#">Next</a></li>
                </ul>
            </div>

I am using Blog Controller here:

$blog = Blog::paginate(2);      

Here is the issues started, Above code, only the links can be generated using links() Method, But not like Simple Previous and Next, so

I Need to implement pagination like

1 2 3 ... Next 

So how could this Possible?,..

0

Out of the box you get both pagination and simplepagination (http://laravel.com/docs/5.1/pagination#basic-usage)

If these don't meet your needs you also get a number of methods that should cover most scenarios:

$results->count()
$results->currentPage()
$results->hasMorePages()
$results->lastPage() (Not available when using simplePaginate)
$results->nextPageUrl()
$results->perPage()
$results->total() (Not available when using simplePaginate)
$results->url($page)

http://laravel.com/docs/5.1/pagination#displaying-results-in-a-view

0

Awesome @elite123 But i can't use above the methods it's showing error like below:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Support\Collection' does not have a method 'currentPage' (View: C:\xampp\htdocs\alterlondon\app\views\frontend\blog\blog_list.blade.php)

I am using this Methods,

  <li class="onpage"><a href="<?php echo $blog->currentPage();?>">1</a></li>
 <li><a href="<?php echo $blog->nextPageUrl();?>">1</a></li>

Or can you please help me how to use methods like currentPage(),lastPage(),nextPageUrl(), For my below used query,

$blog = Blog::paginate(2);      

Thank in Advance

0

Sign in to participate in this thread!

Eventy

Your banner here too?

yokeswar yokeswar Joined 9 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.