Hello! I want to understand how to deal with relationships in the model. Did everything as in this example: https://docs.phalcon.io/en/1.0.0/reference/models.html#relationships-between-models
class ConnexionData extends Model {
public $id;
public $clinic_id;
public $disease_id;
public function getSource() {
return "connexion";
}
public function initialize() {
$this->belongsTo("clinic_id", "NameSpace\Models\ClinicsData", "id", array(
'alias' => 'clinics',
'reusable' => true
));
$this->belongsTo("disease_id", "NameSpace\Models\DiseaseData", "id", array(
'alias' => 'disease',
'reusable' => true
));
}
}
class ClinicsData extends Model {
public $id;
public $name;
public function getSource() {
return "clinics";
}
public function initialize() {
$this->hasMany("id", "NameSpace\Models\ConnexionData", "clinic_id", array(
'alias' => 'сonnexion'
));
}
class DiseaseData extends Model {
public $id;
public $name;
public function getSource() {
return "disease";
}
public function initialize() {
$this->hasMany("id", "NameSpace\Models\ConnexionData", "disease_id", array(
'alias' => 'сonnexion'
));
}
I make a call from the action:
$services = ClinicsData::getClinicDiseaseData($id);
$this->view->setVar("services", $services);
public function getClinicDiseaseData($id) {
$clinic = ClinicsData::find($id);
foreach ($clinic->connexionData as $connexionData) {
$results[] = $connexionData->diseasesData->name;
}
return $results;
}
But the data does not take from the table (Postgres DB).
What could be wrong?