restaurants
을 갖는 users
이 있고, 각각 restaurant
은 comments
입니다.여러 관련 레코드에서 관련 레코드 세트 가져 오기 laravel?
그래서 user
에 로그인하면 의 사용자 목록을 restaurants
과 (과) 관련되었습니다.
나는 지금까지 무엇을 가지고 laravel 5.1
사용하고하는 것은 : 나는 BadMethodCallException
를 얻을 수
$restaurants = $user->restaurants;
$comments = null;
foreach ($restaurants as $restaurant) {
if (!$comments){
$comments = $restaurants->comments();
} else{
$comments = $comments->merge($restaurant->comments());
}
}
$rows = $comments->paginate(15);
$count = $comments->count();
, 나는 이것을 laravel 방법을하고 있지 않다 생각합니다.
은 흠가 보인다 문제가된다면,'사용자'~'레스토랑'은'다 대다 '관계입니다 ... – surfer190