Returns true if the record has any owned relationships that exist
@return bool
556713
public function hasOwned()
    {
        if (!$this->owner->isInDB()) {
            return false;
        }

        $ownedRelationships = $this->owner->config()->get('owns') ?: [];
        foreach ($ownedRelationships as $relationship) {
            /* @var DataObject|SS_List $result */
            $result = $this->owner->{$relationship}();
            if ($result->exists()) {
                return true;
            }
        }

        return false;
    }
264356
public function hasUniqueHash()
    {
        $hash = $this->hashWorkingRecord->{$this->hashDbField} ?: $this->encrypt();

        $list = $this->hashWorkingRecord->get()->filter($this->hashDbField, $hash);

        if($this->hashWorkingRecord->ID) {
            $list = $list->exclude('ID', $this->hashWorkingRecord->ID);
        }

        return !($list->exists());
    }
592720
public function hasUniqueSlug()
    {
        $hash = $this->slugWorkingRecord->{$this->slugDbField} ?: $this->encrypt();
        $list = $this->slugWorkingRecord->get()->filter($this->slugDbField, $hash);

        if($this->slugWorkingRecord->ID) {
            $list = $list->exclude('ID', $this->slugWorkingRecord->ID);
        }
        else {
            $list = $list->exclude('ID', 0);
        }

        return !($list->exists());
    }
461712
public function exists(): bool
    {
        $tableKey = $this->getKeyName();

        //If key isn't set we cant associate this record with DB
        if (! isset($this->$tableKey))
        {
            return false;
        }

        $sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
        $query = DB::getConnection()->prepare($sql);
        $query->execute(['key' => $this->getKey()]);

        return boolval($query->fetchColumn(0));
    }
927262
public function getRelated()
	{
		if($this->parent->getRawColumnValue($this->getForeignKey()) === null)
		{
			return false;
		}

		return $this->first();
	}
1158126
public function hasRelatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                return true;
            }
        }

        return false;
    }
1189404
protected function modelExists()
    {
        $model = $this->option('model');

        if (empty($model)) {
            return true;
        }

        return class_exists($model) && is_subclass_of($model, Model::class);
    }
757013
public function hasDataInDefaultApps()
    {
        $tables = ["post_type", "categories", "tags", "languages", "media"];

        foreach($tables as $table){
            $hasData = DB::table($table)->where("createdByUserID", $this->userID)->count();
            if($hasData) {
                return true;
            }
        }

        return false;
    }
1301925
protected static function _tableExists()
    {
        $db = ConnectionManager::get('default');
        $tables = $db->schemaCollection()->listTables();

        if (in_array('settings_configurations', $tables)) {
            return true;
        }
        return false;
    }
590392
public function exists(): bool
    {
        $key = $this->getStorageKey();

        return $key && $this->getFlexDirectory()->getStorage()->hasKey($key);
    }
112403
public function has()
    {
        $table      = $this->query->getTable();
        $model      = basename(str_replace('\\', '/', get_class($this->parent)));
        $relation   = basename(str_replace('\\', '/', $this->model));
        $localKey   = $this->localKey;
        $foreignKey = $this->foreignKey;

        return $this->parent->db()
            ->alias($model)
            ->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) {
                $query->table([$table => $relation])
                    ->field($relation . '.' . $foreignKey)
                    ->whereExp($model . '.' . $localKey, '=' . $relation . '.' . $foreignKey);
            });
    }
548388
public function owns(Model $related = null, ?string $foreignKey = null): bool
    {
        if (\is_null($related)) {
            return false;
        }

        if (\is_null($foreignKey)) {
            $foreignKey = $this->getForeignKey();
        }

        return $related->getAttribute($foreignKey) == $this->getKey();
    }
919101
protected function isVersioned()
    {
        /** @var Versioned|DataObject $owner */
        $owner = $this->owner;
        return class_exists(Versioned::class)
            && $owner->hasExtension(Versioned::class)
            && $owner->hasStages();
    }
189102
protected function isActualRelationships(string $relation): bool
    {
        return array_key_exists($relation, $this->relationships)
            && count($this->relationships[$relation]) > 0;
    }
1306856
protected function _primaryDataMayHaveRelationships()
    {
        $path = $this->_getPathObject('data.relationships');

        if (!$this->_hasProperty($path)) {
            return true;
        }

        $relationships = $this->_getProperty($path->dotted);

        if (empty($relationships)) {
            $this->_errorCollection->addRelationshipsError(
                $title = '_required',
                $detail = "Relationships object does not contain any members",
                $status = null,
                $idx = null,
                $aboutLink = $this->_getAboutLink('http://jsonapi.org/format/#crud-creating')
            );

            return false;
        }

        foreach ($relationships as $relationship => $data) {
            $relationshipPathObject = $this->_getPathObject($path->dotted . '.' . $relationship);

            if (!$this->_relationshipMustHaveData($relationshipPathObject)) {
                continue;
            }

            if ($this->_relationshipDataIsNull($relationshipPathObject)) {
                continue;
            }

            // single belongsTo relationship
            if ($this->_stringIsSingular($relationshipPathObject->key)) {
                $this->_relationshipDataMustHaveType($relationship, $relationshipPathObject);
                $this->_relationshipDataMustHaveId($relationship, $relationshipPathObject);

                continue;
            }

            // multiple hasMany relationships
            $hasManys = $this->_getProperty($relationshipPathObject->dotted . '.data');

            $i = 0;
            foreach ($hasManys as $hasMany) {
                $pathObject = $this->_getPathObject($relationshipPathObject->dotted . '.data.' . $i);

                $this->_relationshipDataMustHaveType($relationship, $pathObject);
                $this->_relationshipDataMustHaveId($relationship, $pathObject);

                $i++;
            }
        }

        return true;
    }
800304
protected function hasOneOrManyDeepFromRelations(array $relations)
    {
        if (is_array($relations[0])) {
            $relations = $relations[0];
        }

        $related = null;
        $through = [];
        $foreignKeys = [];
        $localKeys = [];

        foreach ($relations as $i => $relation) {
            $method = $this->hasOneOrManyDeepRelationMethod($relation);

            [$through, $foreignKeys, $localKeys] = $this->$method($relation, $through, $foreignKeys, $localKeys);

            if ($i === count($relations) - 1) {
                $related = get_class($relation->getRelated());
            } else {
                $through[] = get_class($relation->getRelated());
            }
        }

        return [$related, $through, $foreignKeys, $localKeys];
    }
472405
private function checkRelationship($method)
    {
        $table = $this->table;

        $one = $table->getOneRelationship();
        $many = $table->getManyRelationship();
        $belongsTo = $table->getBelongsToRelationship();

        $type = null;
        $params = null;

        if (!is_null($one) && array_key_exists($method, $one)) {
            $type = 'one';
            $params = $one[$method];
        }

        if (!is_null($many) && array_key_exists($method, $many)) {
            $type = 'many';
            $params = $many[$method];
        }

        if (!is_null($belongsTo) && array_key_exists($method, $belongsTo)) {
            $type = 'belongsTo';
            $params = $belongsTo[$method];
        }

        if (is_null($type)) {
            return false;
        }

        return $this->parseRelationship($table, $type, $params);
    }