From fd9b8f024745adcc45fd56f567ded84af7c58ba6 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Tue, 18 Sep 2018 17:38:24 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20paginatation=20tweaks,=20added?= =?UTF-8?q?=20sucecss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MetApiController.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/MetApiController.php b/src/MetApiController.php index 0a2f642..d4b106b 100644 --- a/src/MetApiController.php +++ b/src/MetApiController.php @@ -47,9 +47,9 @@ protected function addMeta($name, $value) { $this->meta[$name] = $value; } - protected function paginate($collection) { + protected function paginate($collection,$perpage=15) { - $collection = $collection->paginate(); + $collection = $collection->paginate($perpage); $paginator = new Paginator( $collection->total(), @@ -161,11 +161,21 @@ protected function error($key='unknown',$message='Unknown Error') { return $this->render(['errors' => $this->errors], false, false, 500); } + /** + * Render success + * @param string + * @return \Illuminate\Http\Response + */ + protected function success($message='Successful') + { + return $this->render(['success' => true,'type' => 'success', 'message' => __($message)]); + } + /** * Final output * @param mixed $data data to be sent * @param integer $code response code, defaulting to 200 - * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response + * @return \Illuminate\Http\Response */ protected function render($data=false,$code=200) {