I need to set a follower by following the (myFriends) hasFriend logic for my project. The column "odobera" means "next" for example nick (id user) odobera (next to this user). User (25) is the next user (37).
Query table:

User entity: protected $followers; protected $myFriends; public function __construct() { parent::__construct(); $this->followers = new \Doctrine\Common\Collections\ArrayCollection(); $this->myFriends = new \Doctrine\Common\Collections\ArrayCollection(); } public function getMyFriends() { return $this->myFriends; } public function hasFriend(User $user) { return $this->myFriends->contains($user); } class Requests { protected $nick; protected $odobera;
In the controller:
$myFollowers=$user->getMyFriends();
returns:

What's good: returns 1 record. I actually follow one person, as you can see here the record identifier is 24395
Database query table:

I don’t know if it’s good that the getMyFriends function returns a response in this “format”. Please study it carefully.
Then I select the followers from the query and in the loop:
{% for follower in followers %} and i print data like this (works greate) {{ follower.nick }} or if i want some fields from user entity {{ follower.nick.rank }} {% endfor %}
But the problem is here:
{% if (app.user.hasFriend(follower.nick)) %}
What returns false, why? I follow this user as I checked in the controller with a dump: P A few lines.
source share