So here is what I did to get it work, but if anyone knows better solution please advise!
// User model: overriden getAttribute method
public function getAttribute($key)
{
if ($key == 'reviews')
{
if ( ! array_key_exists($key, $this->getRelations()))
{
$this->load($key);
}
$this->getRelation($key)->setParent($this->getKey());
}
return parent::getAttribute($key);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community