Skip to content

kai-zer-ru/LaravelUnionPaginator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Union Paginator

Latest Version on Packagist Licence Build Status Total Downloads Latest Stable Version

Russian ReadMe

Russian ReadMe here

About

Paginator for questions, with Union

Install

composer require kaizer666/laravel-union-paginator

Usage

use Union\UnionPaginator;

function test() {
    $data = Model::select(["id", "firstname"])
      ->whereIn("id", [1,2,3]);
    $data2 = OtherModel::select(["id", "firstname"])
      ->whereIn("id", [4,5,6])
      ->union($data);
    $paginator = new UnionPaginator();
    $response = $paginator
      ->setQuery($data2)
      ->setCurrentPage(28)
      ->setPerPage(20)
      ->getPaginate();
    $response["pagination"] = $paginator->links(); // html paginator
    $response["pagination_json"] = $paginator->linksJson(); // Json paginator
    return response()->json(
      $response
    );
}

Testing

$ composer test

Credits

License

The MIT License (MIT)