Skip to content

Commit

Permalink
Add ability to specify per_page value on getAll request (#21)
Browse files Browse the repository at this point in the history
* Bringing dev up to speed (#19)

* Bug fix (#16)

* Bug fix

Bug fix for:
specialtactics/laravel-api-boilerplate#26

* Update RestfulTransformer.php

* Update RestfulTransformer.php

StyleCI ?!

* Add test for situation where model has a PK of "id"

* Add tests for empty attributes cast to array

* Some updates for laravel 6 (#18)

* Updates for Laravel 6

* Remove PHP 7.1 from Travis (no longer supported)

* Bump illuminate/support dep version

* Bump orchestra testbench version for laravel 6

* Allow phpunit 8

* Replace str_ helper

* replace assertEquals with assertEqualsWithDelta when using delta

* Add phpunit result cache to gitignore

* Update travis config

* Different config try

* Cater testing for laravel 5.8 as well

* Commit a test to run first and eat up bootstrap time

* Add ability to specify per_page value on getAll request

* Newline oddity
  • Loading branch information
specialtactics authored Oct 21, 2019
1 parent c27cc28 commit aa3d120
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Http/Controllers/RestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function getAll()
// Handle pagination, if applicable
$perPage = $model->getPerPage();
if ($perPage) {
// If specified, use per_page of the request
if (request()->has('per_page')) {
$perPage = intval(request()->input('per_page'));
}

$paginator = $query->paginate($perPage);

return $this->response->paginator($paginator, $this->getTransformer());
Expand Down

0 comments on commit aa3d120

Please sign in to comment.