Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasMany relation #1

Open
oleg-demidov opened this issue Jul 5, 2019 · 0 comments
Open

hasMany relation #1

oleg-demidov opened this issue Jul 5, 2019 · 0 comments

Comments

@oleg-demidov
Copy link

Return value of klisl\behaviors\JsonBehavior::onAfterFind() must be an instance of klisl\behaviors\void, none returned

  1. in /var/www/instagram.test/vendor/klisl/yii2-json-behavior/src/JsonBehavior.php at line 62
    53545556575859606162636465666768697071 {
    /** @var ActiveRecord $model */
    $model = $event->sender;
    $jsonField = $this->getJsonField($model);
    $attribute = $model->getAttribute($jsonField);

     if(!is_array($attribute)){
         $model->{$this->property} = Json::decode($attribute);
     }
    

    }

    public function onBeforeSave(Event $event): void
    {
    /** @var ActiveRecord $model */
    $model = $event->sender;
    $jsonField = $this->getJsonField($model);

     $model->setAttribute($jsonField, Json::encode($model->{$this->property}));
    

    }

in Media model
public function getMedia() {
return $this->hasMany(Media::class, ['thread_item_id' => 'id']);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant