title: Object of class app\models\Users could not be converted to string in yii
body: <p>I created a two models: 
  Login.php and Users.php</p>
  
  <p>Where the Users.php I will get the data from the Users table.</p>
  
  <p>Then, I have created a LoginController.php which is my controller</p>
  
  <p>Then I ran my app I had received this error:
  Object of class app\models\Users could not be converted to string</p>
  
  <p>These are my codes:</p>
  
  <p>Login.php:</p>
  
  <pre><code>    &lt;code&gt;`&lt;?php
  
  namespace app\models;
  
  use Yii;
  
  /**
   * This is the model class for table "users".
   *
   * @property string $user_id
   * @property string $first_name
   * @property string $last_name
   * @property string $position
   * @property string $username
   * @property string $password
   * @property string $dept_id
   */
  class Login extends \yii\db\ActiveRecord
  {
      public $post;
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'users';
      }
  
      /**
       * @inheritdoc
       */
  
      public static function getUsers()
      {
          $post = Users::find()
      -&gt;where(['user_id' =&gt; 1])
      -&gt;one();
  
      return $post;
  
      }
  }`&lt;/code&gt;
  </code></pre>
  
  <p><b>Users.php</b>
      <code>`
  
  <pre><code>namespace app\models;
  
  use Yii;
  
  /**
   * This is the model class for table "users".
   *
   * @property string $user_id
   * @property string $first_name
   * @property string $last_name
   * @property string $position
   * @property string $username
   * @property string $password
   * @property string $dept_id
   */
  class Users extends \yii\db\ActiveRecord
  {
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'users';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['user_id', 'first_name', 'last_name', 'position', 'username', 'password', 'dept_id'], 'required'],
              [['user_id', 'dept_id'], 'string', 'max' =&gt; 10],
              [['first_name', 'last_name'], 'string', 'max' =&gt; 30],
              [['position', 'username', 'password'], 'string', 'max' =&gt; 25],
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'user_id' =&gt; 'User ID',
              'first_name' =&gt; 'First Name',
              'last_name' =&gt; 'Last Name',
              'position' =&gt; 'Position',
              'username' =&gt; 'Username',
              'password' =&gt; 'Password',
              'dept_id' =&gt; 'Dept ID',
          ];
      }
  }
  `&lt;/code&gt;
  </code></pre>
  
  <p><b>LoginController.php</b>
      <code>&lt;?php
      namespace app\controllers;
      use app\models\Login;
      class LoginController extends \yii\web\Controller
      {
          public function actionIndex()
          {
              // $this-&gt;layout = 'loginLayout';
              // $this-&gt;render('index');
              $details = new Login();
              $model = $details-&gt;getUsers();
              $this-&gt;render('index',array('model'=&gt;$model)); 
          }
      }</code></code></p>
  
  <p>I am new in YII I just started studying these</p>
  
  <p>any answers will help thanks</p>