Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data['limit'] = Input::get('limit');
     $data['page'] = Input::get('page');
     $validator = Validator::make($data, ['limit' => 'numeric', 'page' => 'numeric']);
     if ($validator->fails()) {
         return $this->respondUnprocessableEntity();
     }
     $limit = Input::get('limit') ?: 50;
     $limit = $limit < 1 || $limit > 100 ? 10 : $limit;
     $posts = Post::paginate($limit);
     return $this->respondWithPagination($posts, ['posts' => $this->transformer->transformCollection($posts->all())]);
 }