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.

belongsTo and hasMany Relationship


I am using phalcon 3.0, php7 and the newest vokuro version, but i get a notice.

Here is the notice:

Notice: Undefined property: Phalcon\Mvc\Model\Resultset\Simple::$diverse

This is my Papers.php model:

public function initialize()
    $this->belongsTo('usersId', __NAMESPACE__ . '\Users', 'id', [
        'alias' => 'user'

And my Users.php Model:

    $this->hasMany('id', __NAMESPACE__ . '\Papers', 'usersId', [
        'alias' => 'paper',
        'foreignKey' => [
            'message' => 'User cannot be deleted because he/she has activity in the system'

The volt index.volt:

{{ user.paper.diverse }}

Thank you for your help :-)

Rgds Stefan


I think "paper" would be a collection or an array. Try to loop or access within index:

{{ user.paper[0].diverse }}


{% for p in user.paper %}
    {{ p.diverse }}
{% endfor %}


Hello Jimmy Chandra,

thank you for your reply, i will try this at the evening :-)

But in the search.volt of vokuro we have this syntax for volt: {{ }}

How can i reach this? Here is the link:



edited Aug '16

By using hasOne, but then this be 1-1 relation. If you have 1-n relation it's obvious that you need to use array on some point.