Reputation: 62
public function test()
{
return $this->hasMany(MultiTenant::getModel('TestModel'), 'value', 'data->variable');
}
I'm trying to get key value from json column and get related objects but this
data->variable
doesn't work, any solutions?
Upvotes: 0
Views: 1505
Reputation: 116
If I am understanding correctly, you are attempting to retrieve a JSON object, and after doing this, attempting to retrieve the variable value from the data JSON object? In this case, rather than doing
return $this->hasMany(MultiTenant::getModel('TestModel'), 'value', 'data->variable');
You might want to do
return $this->hasMany(MultiTenant::getModel('TestModel'), 'value', 'data')->variable;
If that doesn't work, check what this actually returns:
return $this->hasMany(MultiTenant::getModel('TestModel'), 'value', 'data');
EDIT: Changed to actually check for data.
Upvotes: 2