/** * url GET /v2/teachers * @api * @return string * @throws ApiException */ public function teachersAction() { $allowFilters = ['offset' => true, 'limit' => true, 'showAll' => true, 'showProperties' => true, 'simpleResult' => true]; $allowSearch = ['query' => true]; $params = $this->_fc->getParams(); $filter = $this->_fc->getFilter(); $search = $this->_fc->getSearch(); // check filter if ($filter != null) { Utilities::checkFilters($filter, $allowFilters); } if ($search != null) { Utilities::checkFilters($search, $allowSearch); } if (isset($params[0])) { if ($search == null) { $this->data = TeacherModel::getByNameOrId($params[0]); } } else { if ($search == null) { $showProperties = null; $hideProperties = null; $hidePropertyNames = false; if (isset($filter["showAll"])) { $offset = null; $limit = null; //$showProperties = ['group_full_name'=>true]; $showProperties = is_array($filter["showProperties"]) ? $filter["showProperties"] : []; $hidePropertyNames = isset($filter["simpleResult"]) ? $filter["simpleResult"] : false; } else { $offset = isset($filter['offset']) ? abs(intval($filter['offset'])) : 0; $limit = isset($filter['limit']) ? abs(intval($filter['limit'])) : 100; if ($limit < 1) { $limit = 1; } if ($limit > 100) { $limit = 100; } } $data = TeacherModel::getAll($offset, $limit, $showProperties, $hideProperties, $hidePropertyNames); $this->data = $data['data']; $this->meta = $data['meta']; } else { if (mb_strlen($search['query'], "UTF-8") < 3) { $this->message = "Bad Request! Search query must be less than 2 symbols"; return $this->send(400, Cache::NoCache); } $search['query'] = urldecode($search['query']); $this->data = TeacherModel::searchByName($search['query']); } } return $this->send(200); }
/** * url GET /v2/teachers * @api * @return string * @throws ApiException */ public function teachersAction() { $allowFilters = ['offset' => true, 'limit' => true]; $allowSearch = ['query' => true]; $params = $this->_fc->getParams(); $filter = $this->_fc->getFilter(); $search = $this->_fc->getSearch(); // check filter if ($filter != null) { Utilities::checkFilters($filter, $allowFilters); } if ($search != null) { Utilities::checkFilters($search, $allowSearch); } if (isset($params[0])) { if ($search == null) { $this->data = TeacherModel::getByNameOrId($params[0]); } } else { if ($search == null) { $data = TeacherModel::getAll($filter['offset'], $filter['limit']); $this->data = $data['data']; $this->meta = $data['meta']; } else { if (mb_strlen($search['query'], "UTF-8") < 3) { $this->message = "Bad Request! Search query must be less than 2 symbols"; return $this->send(400, Cache::NoCache); } $search['query'] = urldecode($search['query']); $this->data = TeacherModel::searchByName($search['query']); } } return $this->send(200); }