-1

I have a model like bellow:

 class Book extends ActiveRecord
   {
        { public function getDomain()
        {
            return $this->hasOne(Domain::className(), ['ID' => 'domainID']);
        }

        public function getOwnerPerson()
        {
            return $this->$this->hasOne(Person::className(), ['ID' => 'ownerPersonID']);
        }

        public function getCreatorUser()
        {
            return $this->$this->hasOne(User::className(), ['ID' => 'creatorUserID']);
        }

        public function getUpdaterUser()
        {
            return $this->$this->hasOne(User::className(), ['ID' => 'updaterUserID']);
        }
    }

I've created an object from Book model by follow: $model=Book::find()->all(); when I use $model->domain, every thing is ok, but when I use $model->ownerPerson, it throws an error: Object of class backend\models\Book could not be converted to string

what is the problem?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Rahman
  • 410
  • 6
  • 26

1 Answers1

1

Remove the second $this.

return $this->$this->hasOne(Person::className(), ['ID' => 'ownerPersonID']);
to
return $this->hasOne(Person::className(), ['ID' => 'ownerPersonID']);