-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
I have setup a model MedicalIssue with
_```
/**
* @ogm\ManyToMany(relation="medicalIssue")
*/
protected $symptoms;
function __construct(DoctorPatient $doctorPatient = null)
{
$this->symptoms = new ArrayCollection();
if ($doctorPatient !== null) {
$this->setDoctorPatient($doctorPatient);
}
}
/**
* Gets the value of symptoms.
*
* @return mixed
*/
public function getSymptoms()
{
return $this->symptoms;
}
/**
* Sets the value of symptoms.
*
* @param ArrayCollection $symptoms the symptoms
*
* @return self
*/
public function setSymptoms(ArrayCollection $symptoms)
{
$this->symptoms = $symptoms;
return $this;
}
/**
* Sets the value of symptoms.
*
* @param Symptom $symptom the symptom
*
* @return self
*/
public function addSymptom(Symptom $symptom)
{
$this->symptoms->add($symptom);
return $this;
}
And the other model Symptom with
/**
*
* OGM\ManyToOne(relation="medicalIssue")
*/
protected $medical_issue;
/**
* Gets the OGM\ManyToOne(relation="medicalIssue").
*
* @return mixed;
*/
public function getMedicalIssue()
{
return $this->medical_issue;
}
/**
* Sets the OGM\ManyToOne(relation="medicalIssue").
*
* @param \common\models\MedicalIssue $medical_issue the medical issue
*
* @return self
*/
public function setMedicalIssue(MedicalIssue $medical_issue)
{
$this->medical_issue = $medical_issue;
return $this;
}
Two problems here
1. When calling
$issue->addSymptom($symptom);
$em->persist($issue);
$em->persist($syptom);
$em-flush()
it is saved succesfully
but when
$symptom->setMedicalIssue($symptom)
$em->persist($issue);
$em->persist($syptom);
$em-flush()
The relations is not saving
2. I have checked that the relaltion exists in db
but when calling to the existing medical issue getSymptoms() is always empty
$medicalIssue->findOneBy(['id' => $id]);
$medicalIssue->getSymptoms();
Is there any wrong definition?
Metadata
Metadata
Assignees
Labels
No labels