Sep 9, 2014
0
Level 1
Pagination and Eager Loading
My Controller method is:
$topics=Topic::with(array('subtopics'=>function($query){ $query->with('resources')->orderBy('glc_subtopic_priority','asc')->paginate(1); }))->find($id); return View::make('subtopics.index')->with('topics', $topics); I am eager loading this and it works fine. But now I want to paginate this.
The problem is when I am displaying the data. I am using
@foreach($topics->subtopics as $topic)
{{ $resource->glc_subtopic_resource_url }} @endforeach @endforeach
This returns me the expected result.
But, when I use $topics->links() it returns me an error: Call to undefined method Illuminate\Database\Query\Builder::links()
How can I access this?
Please or to participate in this conversation.