Hello!
Is it possible to do something like:
class ModelA
{
public $data = [
1 => [ 'Element 1' ],
2 => [ 'Element 2' ],
3 => [ 'Element 3' ],
];
}
class ModelB extends Phalcon\Mvc\Model
{
public function getSource()
{
return 'db_table';
}
public function initialize()
{
$this->hasOne('model_a_id', 'ModelA', 'id', [
'alias' => 'modelA'
]);
}
}
$modelB = ModelB::findFirstById(1);
echo $modelB->modelA->name; // Element 1 if db_table.model_a_id = 1
echo $modelB->modelA->name; // Element 3 if db_table.model_a_id = 3