I have a Post model and a Tag model into a many-to-many relationship.
When I get the posts and all tags the post have I use this and it works just fine :
$posts = Post::with(array('tags'))
->where('cat_id', '=', $cat->id)
->where_published(1)
->order_by('created_at', 'desc')
->paginate('10');
The above code shows the latest posts created and paginate them.
I want to achive the same thing but the other way, to start from the tag and get a list of the posts paginated and ordered by created_at column.
Tag::with(array('posts'))
->where('tagname', '=', $tag)
->first();
This works but shows all posts, and I want them paginated, ordered and filtered where_published(1).
Can this be done with eloquent using eager loading (without eager loading I already know to do it but there will be too many queries made) ?
Where can I put the filtering and how to get them paginated ?