0
votes

i'm trying to build forum in my website using Yii2 Podium. But after I installed it I can't access the

podium/home

and I got this message :

Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: common\models\User::newMessagesCount

and this is the Component file

in C:\xampp\htdocs\tugasakhir\vendor\yiisoft\yii2\base\Component.php

public function __get($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        // read property, e.g. getName()
        return $this->$getter();
    }

    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canGetProperty($name)) {
            return $behavior->$name;
        }
    }

    if (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }

    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

What would be the problem?

1
the error is in User Model inside your common/models folder it cannot find the field name in the table user you must be running a select query with count and newMessagesCount is an alias. is it true?Muhammad Omer Aslam
update your question and add your User modelscaisEdge

1 Answers

0
votes

You don't have to change anything in \vendor\yiisoft\yii2\base\Component.php, but you have to controllorae as they set the variables in \models\user.