From the Laravel documentation이 개 다형성 관계 결과를 얻을 -이 대다 다형성 관계가있는 경우 :함께
class Tag extends Eloquent {
public function posts()
{
return $this->morphedByMany('Post', 'taggable');
}
public function videos()
{
return $this->morphedByMany('Video', 'taggable');
}
}
그래서 나는이 작업을 수행 할 수 있습니다
$tag = Tag::find(1);
$posts = $tag->posts;
$videos = $tag->videos;
을 나는 모든 태그를 얻을 수있는 방법 관계를 하나의 결과로? 일대 다 다형성 관계 즉, 당신은이 작업을 수행 :
$tag = Tag::find(1);
$taggable = $tag->taggable;
하지만 나던은 다 대다 관계에서 나를 위해 작동하는 것 -이 SQL 오류 얻을 :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tag_groups.' in 'where clause' (SQL: select * from
tag_groups
wheretag_groups
.`` is null limit 1)
당신이 할 무엇을 기대할 결과를 사용하고 계십니까? Eloquent Collection은 키 중복을 가질 수 있기 때문에 갈 길이 아닙니다. –