Pregunta

I am trying to paginate data from a database using laravel. My code is as follows:

    echo "<table class='table table-striped table-hover'><tbody>";
       $orders=DB::table('customers')->paginate(7);
       foreach ($orders->results as $order):
          echo "<tr><td>".$order->name."</td>
          <td> <button type='button' class='btn btn-sm btn-success pull-right'>
Edit</button></td>
          <td><button type='button' class='btn btn-sm btn-danger pull-right'>
Delete</button></td></tr>"; 
       endforeach; 
    echo "</table>";
       echo $orders->links();

This outputs the paginate links in different lines like so:

« Previous
1
2
Next »

Is it because there is a conflict with bootstrap3? Any help is highly appreciated.

¿Fue útil?

Solución

Although not the best way to handle it, I managed to solve the problem. My solution requires editing the paginator.php inside the vendor folder. Changing

return '<div class="pagination">'.$content.'</div>';

on line 188 to

return $content;

solves the problem.

Otros consejos

Pagination links are a vertical list inside a parent div with a class .pagination. You can solve this by some simple CSS modifications:

.pagination li {
    display: inline;
    margin-left: 0.5em;
    margin-right: 0.5em;
}

This will make the list items inline and add some space between them. Works perfectly for me. I am not sure why laravel uses the links in a list like this in the first place tho.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top