Laravel Eager Loading Polymorphic Relationships

前端 未结 1 989
-上瘾入骨i
-上瘾入骨i 2021-01-16 04:50

Trying to eager load a model and it\'s related model but the related model returns null even though it has related data.

Group Model is polymorphic 1:1 to ei

相关标签:
1条回答
  • 2021-01-16 05:28

    Try this. It might help.

        public function groupable()
    {
        return $this->morphTo('groupable');
    }
    

    I had that problem too earlier, maybe you have the same prob like me. Essentially what I did was to help Laravel finds what columns it needs to look up for.

    0 讨论(0)
提交回复
热议问题