Skip to content

Instantly share code, notes, and snippets.

@ctf0
Forked from vluzrmos/paginate.php
Last active May 19, 2025 14:51
Show Gist options
  • Select an option

  • Save ctf0/109d2945a9c1e7f7f7ea765a7c638db7 to your computer and use it in GitHub Desktop.

Select an option

Save ctf0/109d2945a9c1e7f7f7ea765a7c638db7 to your computer and use it in GitHub Desktop.

Revisions

  1. ctf0 revised this gist May 19, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions paginate.php
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    <?php

    // use Illuminate\Support\Collection;
    // use Illuminate\Pagination\Paginator;
    // use Illuminate\Pagination\LengthAwarePaginator;
    use Illuminate\Support\Collection;
    use Illuminate\Pagination\Paginator;
    use Illuminate\Pagination\LengthAwarePaginator;

    /**
    * Gera a paginação dos itens de um array ou collection.
  2. ctf0 revised this gist Jul 13, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paginate.php
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@
    *
    * @return LengthAwarePaginator
    */
    public function paginate($items, $perPage = 15, $page = null, , $getValues = true)
    public function paginate($items, $perPage = 15, $page = null, $getValues = true)
    {
    $pageName = 'page';
    $page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1);
  3. ctf0 revised this gist Feb 20, 2021. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions paginate.php
    Original file line number Diff line number Diff line change
    @@ -13,14 +13,16 @@
    *
    * @return LengthAwarePaginator
    */
    public function paginate($items, $perPage = 15, $page = null)
    public function paginate($items, $perPage = 15, $page = null, , $getValues = true)
    {
    $pageName = 'page';
    $page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1);
    $items = $items instanceof Collection ? $items : Collection::make($items);

    return new LengthAwarePaginator(
    $items->forPage($page, $perPage)->values(),
    $getValues
    ? $items->forPage($page, $perPage)->values()
    : $items->forPage($page, $perPage),
    $items->count(),
    $perPage,
    $page,
  4. ctf0 revised this gist Nov 9, 2019. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion paginate.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,9 @@
    <?php

    // use Illuminate\Support\Collection;
    // use Illuminate\Pagination\Paginator;
    // use Illuminate\Pagination\LengthAwarePaginator;

    /**
    * Gera a paginação dos itens de um array ou collection.
    *
    @@ -24,4 +29,4 @@ public function paginate($items, $perPage = 15, $page = null)
    'pageName' => $pageName,
    ]
    );
    }
    }
  5. ctf0 revised this gist Jun 22, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions paginate.php
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,8 @@
    * Gera a paginação dos itens de um array ou collection.
    *
    * @param array|Collection $items
    * @param int $perPage
    * @param int $perPage
    * @param int $page
    * @param array $options
    *
    * @return LengthAwarePaginator
    */
  6. ctf0 revised this gist Jun 22, 2018. 1 changed file with 14 additions and 5 deletions.
    19 changes: 14 additions & 5 deletions paginate.php
    Original file line number Diff line number Diff line change
    @@ -9,11 +9,20 @@
    *
    * @return LengthAwarePaginator
    */
    public function paginate($items, $perPage = 15, $page = null, $options = [])
    public function paginate($items, $perPage = 15, $page = null)
    {
    $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
    $pageName = 'page';
    $page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1);
    $items = $items instanceof Collection ? $items : Collection::make($items);

    $items = $items instanceof Collection ? $items : Collection::make($items);

    return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
    return new LengthAwarePaginator(
    $items->forPage($page, $perPage)->values(),
    $items->count(),
    $perPage,
    $page,
    [
    'path' => Paginator::resolveCurrentPath(),
    'pageName' => $pageName,
    ]
    );
    }
  7. @vluzrmos vluzrmos created this gist Jul 20, 2016.
    19 changes: 19 additions & 0 deletions paginate.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    <?php
    /**
    * Gera a paginação dos itens de um array ou collection.
    *
    * @param array|Collection $items
    * @param int $perPage
    * @param int $page
    * @param array $options
    *
    * @return LengthAwarePaginator
    */
    public function paginate($items, $perPage = 15, $page = null, $options = [])
    {
    $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);

    $items = $items instanceof Collection ? $items : Collection::make($items);

    return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
    }