-
-
Save hlmn/d18c7181573801516a15027548d01557 to your computer and use it in GitHub Desktop.
A pageable Collection implementation for Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Support; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
use Illuminate\Support\Collection as BaseCollection; | |
class Collection extends BaseCollection { | |
public function paginate( $perPage, $total = null, $page = null, $pageName = 'page' ) | |
{ | |
$page = $page ?: LengthAwarePaginator::resolveCurrentPage( $pageName ); | |
return new LengthAwarePaginator( $this->forPage( $page, $perPage ), $total ?: $this->count(), $perPage, $page, [ | |
'path' => LengthAwarePaginator::resolveCurrentPath(), | |
'pageName' => $pageName, | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment