Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to define has one or zero relationship between two models

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%}


Just evaluate if the variable is false is enough:

{% if picture %}