Nextras\Orm\Relationships\HasMany::has PHP Метод

has() публичный Метод

public has ( $entity )
    public function has($entity)
    {
        $entity = $this->createEntity($entity, false);
        if (!$entity) {
            return false;
        }
        $entityHash = spl_object_hash($entity);
        if (isset($this->toAdd[$entityHash])) {
            return true;
        } elseif (isset($this->toRemove[$entityHash])) {
            return false;
        } elseif (!$entity->isPersisted()) {
            return false;
        } else {
            return (bool) $this->getCollection()->getBy(['id' => $entity->getValue('id')]);
        }
    }