Seperated $userId and $user?

Is class like that gonna work ? Can i normally access only userId by getUserId() and getUser() will get related User model ?

class SomeClass extends Model
{
    protected $id;
    protected $userId;
    protected $user;

    public function initialize()
    {
        $this->belongsTo('userId','User','id',array('alias'=>'user'));
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function getUser()
    {
        return $this->getRelated('user');
    }
}

Is that gonna work without any problems ? Sometimes i just only need user id, dont need to select whole related model.

Hi I don't know if i understand fully your problem. If you use the belongsTo with an alias as you do, then the related "User" will be availeble through SomeClass->getUser() without the function "public function getUser()" that you have defined. (See https://docs.phalconphp.com/en/latest/reference/models.html#relationships-between-models)