2016-06-18 1 views
1

내가 오류를 정의되지 않은 메서드를 분명히 \ 데이터베이스에Laravel 5 - 정의되지 않은 메서드를 분명히 데이터베이스에 전화 웅변 컬렉션 :: 페이지를 매기는()

전화 데 \ 웅변 \ 컬렉션 :: 페이지를 매기는()

나는이 일을 봤는데 :

public function index() 
{ 

    $articles = Article::latest('published_at')->published()->get()->paginate(5); 
    $articlesLink = $articles->render(); 

    return view('articles.index', compact('articles', 'articlesLink')); 
} 

답변

2

변경해보십시오

,210

->get()를 호출하여

$articles = Article::latest('published_at')->published()->paginate(5); 

에, 당신은 다시 Collection 객체를 받고있을 것, 그리고 Collection 객체에는 paginate() 방법, 따라서 오류가 없습니다.

+0

감사합니다. get()을 제거했을 때 완벽하게 작동합니다. –