I have two table in symfony. The images table has a foreign key to the users table. I want to retrieve records where user id is equal to the argument passed. Here is my attempt
private function serializeUsers(Users $usr) {
return array(
'username' => $usr->getUsername(),
'email' => $usr->getEmail(),
'id' => $usr->getId(),
//I have tried using getter method to retrieve image value here but I cannot because image is related to users
);
}
Here is the controller codes
$restresults = $this->getDoctrine()
->getRepository('xxxBundle:Users')
->findBy(['id' => $id]);
array_push($data, $this->serializeUsers($restresult));
As you can see from my above attempts, I am unable to retrieve data for the image table having a foreign key to the users table. Is my design wrong or I have not yet figured out the logic or a better way to approach this