Answer the question
In order to leave comments, you need to log in
Combining two queries and outputting them to pagination how?
How to combine two requests in the controller and then display them in pagination?
In the view, there is no particular desire to do two pieces of forich
Example:
$goods1 = Goods::where('siteID', $siteID)->where('popular', 1)->get();
$goods2 = Goods::where('siteID', $siteID)->where('popular', 2)->get();
vivod = goods1 + goods2 ->paginate(12)
Answer the question
In order to leave comments, you need to log in
$goods1 = Goods::where('siteID', $siteID)->where('popular', 1);
$goods2 = Goods::where('siteID', $siteID)->where('popular', 2);
$vivod = $goods1->unionAll($goods2)->paginate(12);
Have you read the documentation on collections ?
Although I see that I need to read the Query Builder documentation, because if both queries return at least a hundred options, then it will be fun.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question