title: Why am I getting "Class 'app\models\Yii' not found" error?
body: <p>Model's function for which I got this error:</p>
  
  <pre><code>public function setPassword($password)
  {
      $this-&gt;password_hash = Yii::$app-&gt;security-&gt;generatePasswordHash($password);
  }
  
  public function generateAuthKey()
  {
      $this-&gt;auth_key = Yii::$app-&gt;security-&gt;generateRandomString();
  }
  </code></pre>