/** * Approve friend request. * * @param Relationship $relationship */ public function approveFriendRequest(Relationship $relationship) { $startNode = $relationship->getStartNode(); $endNode = $relationship->getEndNode(); $relationship->delete(); $startNode->relateTo($endNode, 'FRIENDS')->save(); $endNode->relateTo($startNode, 'FRIENDS')->save(); }
/** * Set a given relationship on this relation. * * @param \Everyman\Neo4j\Relationship $relation */ public function setRelation(Relationship $relation, $debug = false) { // Set the relation object. $this->relation = $relation; // Replace the attributes with those brought from the given relation. $this->attributes = $relation->getProperties(); $this->setAttribute($this->primaryKey, $relation->getId()); // Set the start and end nodes. $this->start = $relation->getStartNode(); $this->end = $relation->getEndNode(); // Instantiate and fill out the related model. $relatedNode = $this->isDirectionOut() ? $this->end : $this->start; $attributes = array_merge(['id' => $relatedNode->getId()], $relatedNode->getProperties()); // This is an existing relationship. $exists = true; $this->related = $this->related->newFromBuilder($attributes, $exists); $this->related->setConnection($this->related->getConnection()); }