Closed mefenlon closed 5 years ago
Have you figured this out? Im having similiar issues.
Looks like a known issue https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/142 I am going to attempt to add pagination to the model as suggested in the above thread.
@mefenlon Thanks for some reason though adding the paginate macro was still returning unexpected results. I got around it by returning the builders results and creating a new collection from those results and paginating that instead:
See my comment:
I ended up with something similar.
This would be much clearer if the README was correct. $department comes out of nowhere
//$department?
$paginator` = $department->paginate(10);
$posts` = $paginator->getCollection();
// return posts
I have a few scopes that I am using for constraints. When they are not triggered, the pagination functions fine. But If a constraint is uses, the pagination acts as if the full set (527) is there even though the collection contains the correct number results (6)
//Output with no constraints LengthAwarePaginator {#623 ▼
total: 527
lastPage: 22
items: Collection {#677 ▼
}
perPage: 25
currentPage: 1
path: "http://localhost:8000/illustrations"
query: array:1 [▼
]
fragment: null
pageName: "page"
}
//With constraint ( LengthAwarePaginator {#623 ▼
total: 527
lastPage: 22
items: Collection {#677 ▼
}
perPage: 25
currentPage: 1
path: "http://localhost:8000/illustrations"
query: array:1 [▼
]
fragment: null
pageName: "page"
}