/** * Display a listing of the resource. * * @return Response */ public function index() { $boards = Board::orderBy('created_at', 'desc'); if (Input::has('fields')) { $fields = explode(',', Input::get('fields')); $boards = $boards->select($fields); } if (Input::has('list')) { $list = explode(',', Input::get('list')); $boards = $boards->where(function ($boards) use($list) { $boards->orWhereIn('id', $list)->orWhereIn('code', $list); }); } if (Input::has('limit')) { $limit = Input::get('limit'); $offset = Input::get('offset', 0); $boards = $boards->skip($offset)->take($limit)->get(); } else { $boards = $boards->get(); } if (!Input::has('fields') or Input::has('fields') && in_array('using_status', $fields)) { $response = []; $from = Input::get('from', date('Y-m-d')); $end = Input::get('end', date('Y-m-d')); foreach ($boards as $board) { $isUsing = $board->getUsingStatus($from, $end); $response[] = array_merge($board->toArray(), ['using_status' => $isUsing]); } $boards = $response; } return Response::json($boards); }