/** * Relation constructor. * @param Model $source * @param $attribute */ public function __construct(Model $source, $attribute) { list($this->model, $this->type) = $source->getRelations()[$attribute]; if ($this->isRel()) { $this->classPath = 'Afosto\\ApiClient\\Models\\' . Inflector::pluralize($this->_getModelForRel()) . '\\' . $this->model; } else { if ($this->isReference()) { $this->classPath = 'Afosto\\ApiClient\\Models\\' . Inflector::pluralize($this->_getModelForReference()) . '\\' . $this->_getModelForReference(); } else { $this->classPath = $source->getNameSpace() . '\\' . $this->model; } } }
/** * Returns the totalCount * @return integer */ public function getTotalCount() { if (is_null($this->_totalCount)) { $count = $this->_owner->findCount(); $this->_totalCount = $count->total; } return $this->_totalCount; }
/** * Map model data * @return array */ protected function getMapping() { return array_merge([], parent::getMapping()); }
/** * Update the pagination data accordingly to the results of the last request */ private function _updatePagination() { if (!empty($this->_response->getHeader(ApiHelper::HEADER_TOTAL_COUNT))) { $this->_owner->getPagination()->update(current($this->_response->getHeader(ApiHelper::HEADER_TOTAL_COUNT))); } }