“Laravel Custom Pagination” Code-Antworten

benutzerdefinierte Bootstrap -Pagination Laravel

php artisan vendor:publish --tag=laravel-pagination
ashik

Paginate Beziehung Laravel7

$category = Category::first();
$apps = $category->apps()->paginate(10);
return view('example', compact('category', 'apps'));
Zeevx

Laravel Multiple Paginat

# use default 'page' for this
$collection1 = Model::paginate(20);

# use custom 'other_page' for this
$collection2 = Model2::paginate(20);
$collection2->setPageName('other_page');
Frail Fowl

Custom Pagination Laravel CSS

php artisan vendor:publish --tag=laravel-pagination
  OR
use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::defaultView('your-pagination-view-name');

}
@marlino

LaRavel -Paginierungs -Layout -Problem

/**
 * AppServiceProvider.php
 */

use Illuminate\Pagination\Paginator; // Don't forget this

public function boot ()
{
      Paginator::useBootstrap();	// Add this
}
Beautiful Bee

Laravel Custom Pagination

<?php
// config
$link_limit = 7; // maximum number of links (a little bit inaccurate, but will be ok for now)
?>

@if ($paginator->lastPage() > 1)
    <ul class="pagination">
        <li class="{{ ($paginator->currentPage() == 1) ? ' disabled' : '' }}">
            <a href="{{ $paginator->url(1) }}">First</a>
         </li>
        @for ($i = 1; $i <= $paginator->lastPage(); $i++)
            <?php
            $half_total_links = floor($link_limit / 2);
            $from = $paginator->currentPage() - $half_total_links;
            $to = $paginator->currentPage() + $half_total_links;
            if ($paginator->currentPage() < $half_total_links) {
               $to += $half_total_links - $paginator->currentPage();
            }
            if ($paginator->lastPage() - $paginator->currentPage() < $half_total_links) {
                $from -= $half_total_links - ($paginator->lastPage() - $paginator->currentPage()) - 1;
            }
            ?>
            @if ($from < $i && $i < $to)
                <li class="{{ ($paginator->currentPage() == $i) ? ' active' : '' }}">
                    <a href="{{ $paginator->url($i) }}">{{ $i }}</a>
                </li>
            @endif
        @endfor
        <li class="{{ ($paginator->currentPage() == $paginator->lastPage()) ? ' disabled' : '' }}">
            <a href="{{ $paginator->url($paginator->lastPage()) }}">Last</a>
        </li>
    </ul>
@endif
Friendly Ferret

Ähnliche Antworten wie “Laravel Custom Pagination”

Fragen ähnlich wie “Laravel Custom Pagination”

Weitere verwandte Antworten zu “Laravel Custom Pagination” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen