I have a problem with using morphMany relations in combination with lists in my model. I do have a Meta model (morphMany) and a Resort model. The Resort model has a method metas() that just does this: return $this->morphMany('Meta', 'metable');
public function metas()
{
return $this->morphMany('Meta', 'metable')->lists('value', 'key');
}
Now what I want to have is a key/value list, just like I am able to do with hasMany: return $this->morphMany('Meta', 'metable')->lists('value', 'key'); But this doesn't work. If I use the same with hasMany on a different table, it works fine, so I assume there must be a difference between hasMany and morphMany in terms of the object structure.
The error I get is: Call to a member function addEagerConstraints() on a non-object [/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php, Line 471] (Laravel 4.2.8)
I hope any of you can help me with this issue.
Thanks a lot in advance.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community