I have the ids returned from an immense query to bring the posts with a searched term ... It is already working to bring the posts through the Model by the selected IDS but it always brings by ID and what I need to order by date ... In the huge query I've done, I already have the IDs sorted correctly, but when I use the IDS lookup template, it gets cluttered and sorted by ID ... Code example:
$terms = explode(' ', Input::get('search'));
$results =
DB::select(
DB::raw($this->getSearchQuery($terms))
);
$postIds = [];
foreach ($results as $result) {
array_push($postIds, $result->id);
}
$posts = Post::find($postIds);
The problem is in the last line that instead of looking for the IDS in the order that I inform, it searches in the ordered by ID ...