I am querying DB posts via a Laravel eloquent controller and would like to first filter the posts and then paginate.
$filter = ['author_id' => $id, 'status' => 'live', 'type' => $type];
$posts = Post::where($filter)->orderBy('id','desc')->get();
$posts = Post::paginate(1, ['*'], 'page', $page);
return $posts;
Of course currently it is only going to paginate. How can I combine both $posts so that the filtered results are paginated?
Thanks!