Paginate API incidents
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
|
||||
use CachetHQ\Cachet\Transformers\IncidentTransformer;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
@@ -37,7 +38,9 @@ class IncidentController extends Controller
|
||||
*/
|
||||
public function getIncidents()
|
||||
{
|
||||
return $this->incident->all();
|
||||
$incidents = $this->incident->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->response->paginator($incidents, new IncidentTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,18 @@ abstract class EloquentRepository
|
||||
return $this->model->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns paginated result.
|
||||
*
|
||||
* @param int $perPage
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function paginate($perPage = 20)
|
||||
{
|
||||
return $this->model->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with related relationships.
|
||||
*
|
||||
|
||||
@@ -11,6 +11,15 @@ interface IncidentRepository
|
||||
*/
|
||||
public function all();
|
||||
|
||||
/**
|
||||
* Returns paginated result.
|
||||
*
|
||||
* @param int $perPage
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function paginate($perPage = 20);
|
||||
|
||||
/**
|
||||
* Create a new model.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user