public function index(Request $request) { $limit = $request->input('limit') ? $request->input('limit') : 10; $page = $request->input('page') ? $request->input('page') : 1; $offset = ($page - 1) * $limit; $total = Campaign::count(); $dataCampaigns = Campaign::take($limit)->offset($offset)->get(); $data = ['meta' => ['page' => (int) $page, 'current_total' => count($dataCampaigns), 'total' => $total], 'campaigns' => $dataCampaigns]; return $data; }