/** * @param DbObject $user * @param mixed $onFailReturn * @return mixed|DbObject */ protected function validateUser(DbObject $user, $onFailReturn = null) { if ($user->exists() && (!$user->_hasField('is_active') || $user->is_active) && (!$user->_hasField('is_banned') || !$user->is_banned)) { return $user; } return $onFailReturn; }
/** * @param int|string|array|DbObject $record * @param bool $cleanRelatedModelsCache * @throws DbModelException * @throws \BadMethodCallException * @throws \PeskyORM\Exception\DbConnectionConfigException * @throws \PeskyORM\Exception\DbObjectException * @throws \PeskyORM\Exception\DbUtilsException * @throws \InvalidArgumentException */ public function cleanRecordCache($record, $cleanRelatedModelsCache = null) { /** @var CmfDbModel|TaggedCacheForDbSelects $this */ if (!$record instanceof DbObject || $record->exists()) { \Cache::tags($this->getRecordCacheTag($record))->flush(); } $this->cleanRelatedModelsCache($cleanRelatedModelsCache); }