Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 4.x Pagination

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 92
    Comment on it

    It is very painful to use pagination in other framework but In laravel 4.x. It is very easy to implement pagination in laravel 4.x. By using configuration option in

    app/config/view.php 
    

    file. Pagination option specifies that which view file is used for pagination.

    In laravel we have by default 2 type of views.
    *) Pagination::slider
    *) Pagination::simple

    Using Pagination with Query

    We have paginate method for implement pagination in laravel 4.x.


    Example

    $examples = DB::table('users')->paginate(15);
    

    In View

    <div class="container">
        <?php foreach ($examples as $example): ?>
            <?php echo $example->name; ?>
        <?php endforeach; ?>
    </div>
    
    <?php echo $examples->links(); ?>
    

    Here link is used to create pagination link.

    There are many more additional methods such as

    1. getCurrentPage
    2. getLastPage
    3. getPerPage
    4. getTotal
    5. getFrom
    6. getTo
    7. count

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: