{"id":15471000,"url":"https://github.com/jackardios/elastic-json-api-paginate","last_synced_at":"2026-04-26T16:32:25.748Z","repository":{"id":56995383,"uuid":"414085145","full_name":"Jackardios/elastic-json-api-paginate","owner":"Jackardios","description":"ElasticScoutDriverPlus extension for spatie/laravel-json-api-paginate","archived":false,"fork":false,"pushed_at":"2021-10-12T07:12:17.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T01:13:59.725Z","etag":null,"topics":["json-api","laravel","paginate","php","scout"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jackardios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-06T05:48:25.000Z","updated_at":"2021-10-12T07:12:20.000Z","dependencies_parsed_at":"2022-08-21T13:50:40.197Z","dependency_job_id":null,"html_url":"https://github.com/Jackardios/elastic-json-api-paginate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jackardios%2Felastic-json-api-paginate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jackardios%2Felastic-json-api-paginate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jackardios%2Felastic-json-api-paginate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jackardios%2Felastic-json-api-paginate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jackardios","download_url":"https://codeload.github.com/Jackardios/elastic-json-api-paginate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246034280,"owners_count":20712851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-api","laravel","paginate","php","scout"],"created_at":"2024-10-02T02:08:20.713Z","updated_at":"2026-04-26T16:32:25.706Z","avatar_url":"https://github.com/Jackardios.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A paginator that plays nice with the JSON API spec\n\nThis package is just [ElasticScoutDriverPlus](https://github.com/Jackardios/elastic-scout-driver-plus/) extension for [spatie/laravel-json-api-paginate](https://github.com/spatie/laravel-json-api-paginate)\n\nIn a vanilla Laravel application [the query builder paginators will listen to `page` request parameter](https://laravel.com/docs/master/pagination#paginating-query-builder-results). This works great, but it does follow the example solution of [the json:api spec](http://jsonapi.org/). That example [expects](http://jsonapi.org/examples/#pagination) the query builder paginator to listen to the `page[number]` and `page[size]` request parameters. \n\nThis package adds a `jsonPaginate` method to the Scout query builder that listens to those parameters and adds [the pagination links the spec requires](http://jsonapi.org/format/#fetching-pagination).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require jackardios/elastic-json-api-paginate\n```\n\nIn Laravel 5.5 and above the service provider will automatically get registered. In older versions of the framework just add the service provider in `config/app.php` file:\n\n```php\n'providers' =\u003e [\n    ...\n    Spatie\\JsonApiPaginate\\JsonApiPaginateServiceProvider::class,\n    Jackardios\\ElasticJsonApiPaginate\\JsonApiPaginateServiceProvider::class,\n];\n```\n\nOptionally you can publish the config file with:\n\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\JsonApiPaginate\\JsonApiPaginateServiceProvider\" --tag=\"config\"\n```\n\nThis is the content of the file that will be published in `config/json-api-paginate.php`\n\n```php\n\u003c?php\n\nreturn [\n\n    /*\n     * The maximum number of results that will be returned\n     * when using the JSON API paginator.\n     */\n    'max_results' =\u003e 30,\n\n    /*\n     * The default number of results that will be returned\n     * when using the JSON API paginator.\n     */\n    'default_size' =\u003e 30,\n\n    /*\n     * The key of the page[x] query string parameter for page number.\n     */\n    'number_parameter' =\u003e 'number',\n\n    /*\n     * The key of the page[x] query string parameter for page size.\n     */\n    'size_parameter' =\u003e 'size',\n\n    /*\n     * The name of the macro that is added to the Scout query builder.\n     */\n    'method_name' =\u003e 'jsonPaginate',\n\n    /*\n     * If you only need to display Next and Previous links, you may use\n     * simple pagination to perform a more efficient query.\n     *\n     * THIS CONFIGURATION IS NOT SUPPORTED IN jackardios/elastic-json-api-paginate\n     */\n    'use_simple_pagination' =\u003e false,\n\n    /*\n     * Here you can override the base url to be used in the link items.\n     */\n    'base_url' =\u003e null,\n\n    /*\n     * The name of the query parameter used for pagination\n     */\n    'pagination_parameter' =\u003e 'page',\n];\n```\n\n## Usage\n\nTo paginate the results according to the json API spec, simply call the `jsonPaginate` method.\n\n```php\nYourModel::searchQuery(...)-\u003ejsonPaginate();\n```\n\nOf course you may still use all the builder methods you know and love:\n\n```php\nYourModel::searchQuery(...)-\u003esort('my_field', 'desc')-\u003ejsonPaginate();\n```\n\nBy default the maximum page size is set to 30. You can change this number in the `config` file or just pass the value to  `jsonPaginate`.\n\n```php\n$maxResults = 60;\n\nYourModel::searchQuery(...)-\u003ejsonPaginate($maxResults);\n```\n\nBy default ElasticScoutDriverPlus paginates raw results, if you want to paginate models, call the `onlyModels` method after `jsonPaginate`\n\n```php\nYourModel::searchQuery(...)-\u003ejsonPaginate()-\u003eonlyModels();\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackardios%2Felastic-json-api-paginate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackardios%2Felastic-json-api-paginate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackardios%2Felastic-json-api-paginate/lists"}