class Users extends \Phalcon\Mvc\Model {
public function initialize() {}
//has one or zero
$this->hasOne('id', 'UserPictures', 'users_id', ['alias' => 'picture']);
}
}
class UserPictures extends \Phalcon\Mvc\Model {
public function initialize() {
$this->hasOne('users_id', 'Users', 'id', ['alias' => 'user']);
}
}
controller action:
$user = Users::findFirst();
$picture = $user->picture;
$this->view->picture = $picture;
in volt template:
{%if picture is defined%}
.
.
.
{%endif%}