I have two tables Posts
and Tags
with many to many
relation. I need to retrieve all posts by some tag and paginate it. Is it possible to do with paginate
method or I need to create a new instance of Paginator
and do everything by hand?
P.S. Need something like:
$tags = Tags::where('name', '=', $tag)->with('posts')->first();
$posts = $tags->posts->paginate(5);
return view('blog/posts')->with('posts', $posts);