New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

denmasyarikin/laravel-api-pagination

API Pagination For Laravel & Lumen
343
Install
composer require denmasyarikin/laravel-api-pagination
Latest Version:0.1.8
PHP:>=7.0
License:MIT
Last Updated:Dec 23, 2021
Links: GitHub  ·  Packagist
Maintainer: denmasyarikin

Note

Inspired By Illuminate Pagination, This Package Used For Api Pagination (by limit/offset)

Changelog

  • 0.1.6 Fix Wrong Default Limit Value
  • 0.1.5 Fix Error When No Data
  • 0.1.4 Fix Typo.
  • 0.1.3 Fix Scope.
  • 0.1.2 Bump Version.
  • 0.1.1 Fix Unresolved Dependency.
  • 0.1.0 Init Version.

How to install (steps)

1. Install using Composer

composer require "elemenx/laravel-api-pagination"

2. Required changes in bootstrap/app.php (If using Lumen)

On bootstrap/app.php add:

$app->register(ElemenX\ApiPagination\PaginationServiceProvider::class);

3.Add Trait in Your Models

use ElemenX\ApiPagination\Paginatable;

class User {
    use Paginatable;
}

Example

This is an example for how to use this package.

$users = User::apiPaginate(100); // 100 is your defalut limit number

when you visit with

http://api.dev/user?limit=100&offset=0

It will return Structure As follows.

[
    'data' => [
        [
            'id' => 1,
            'name' => 'test'
        ]
    ],
    'meta' => [
        'limit' => 100,
        'offset' => 0,
        'total' => 1
    ]
]

Related Packages

elemenx/laravel-api-pagination

API Pagination For Laravel & Lumen

12,924 2
bwt-team/laravel-api

Package helping with API development

11,339 1
chelout/offset-pagination

Offset pagination made easy for Laravel

4,963 4
noitran/lumen-form-requests

Missing form requests functionality for lumen, ported from laravel framework.

4,750 5
nebo15/lumen.rest

Components for fast building REST API for Lumen

3,759 1

Version History

Version Released PHP License
0.1.8 >=7.0 MIT
0.1.7 >=7.0 MIT
0.1.6 >=7.0 MIT
0.1.5 >=7.0 MIT
0.1.4 >=7.0 MIT