/** * Display a listing of the resource. * * @return Response */ public function index() { // What's wrong with the following return statement: // 1. All is bad // 2. No way to attach meta data // 3. Linking db structure to the API output // 4. No way to signal headers/response codes // return Lesson::all(); // really bad practice // $lessons = Lesson::all(); $limit = request('limit') ?: 3; $lessons = Lesson::paginate($limit); // dd(get_class_methods(paginate())); // return response()->json([ return $this->respondWithPagination($lessons, ['data' => $this->lessonTransformer->transformCollection($lessons->all())]); }