I've got a class I'm initializing from my Controller:
<?PHP
namespace Model;
class Contact extends Person{
public function getSource(){
return 'person';
}
public function initialize(){
$this->hasMany('username','\Model\Organization','contact_username',['alias'=>'Organizations']);
$this->hasOne('username','\Model\PersonContact','username',['alias'=>'Additional']);
}
public function isAssociated(){
if(count($this->Organizations)){
return TRUE;
}
return FALSE;
}
}
From my controller (and view), I get a WTF error
$Contact = Person::findFirstAsType($username);
echo $Contact->Additional->position; // This generates an error
echo $Contact->getRelated('Additional')->position; // This works just fine
Any ideas as to why the alias fails, but getRelated()
works?