Laravel 4 - paginate ignore distinct in Fluent

前端 未结 2 1709
既然无缘
既然无缘 2021-01-22 16:41

I make fluent request with distinct and paginate. My problem is that the paginate request is execute before disinct request

My Fluent request :

$candidat         


        
相关标签:
2条回答
  • 2021-01-22 17:03

    Blind guess : try

    DB::table('candidates')->...stuff...->get()->paginate(15)

    Real answer: Create your paginator manually:

    $candidates = DB::table('candidates')->...stuff...->get();
    
    $paginator = Paginator::make($candidates, count($candidates), 15);
    
    0 讨论(0)
  • 2021-01-22 17:20
    <?php
         $presenter = new Illuminate\Pagination\BootstrapPresenter($candidates);
         $presenter->setLastPage($totalPages);
    ?>
    
    @if ($totalPages> 1)
         <ul class="pagination">
              {{ $presenter->render() }}
         </ul>
    @endif
    
    0 讨论(0)
提交回复
热议问题