PHP code example of stepanenko3 / laravel-pagination

1. Go to this page and download the library: Download stepanenko3/laravel-pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stepanenko3 / laravel-pagination example snippets

 php
use Stepanenko3\LaravelPagination\Pagination;
use Illuminate\Database\Eloquent\Builder;

class BaseBuilder extends Builder
{
    public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Pagination::resolveCurrentPage($pageName);
        $perPage = $perPage ?: $this->model->getPerPage();
        $results = ($total = $this->toBase()->getCountForPagination())
            ? $this->forPage($page, $perPage)->get($columns)
            : $this->model->newCollection();

        return new Pagination($results, $total, $perPage, $page, [
            'path' => Pagination::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
}
 php
new Pagination(
    $items,
    $total,
    $perPage,
    $currentPage,
);