【发布时间】:2022-01-10 08:42:21
【问题描述】:
我有一个“主要”查询,我想打破它的链并将数据共享给不同的案例;
$products = Product::where('is_active', 1)->where('date', '>', $blabla);
我想拆分它的数据,例如:
$type_1 = $products->where('type', 1)->groupBy('x')->orderBy('x')->get();
$type_2 = $products->where('type', 2)->groupBy('x')->orderBy('x')->get();
$type_3 = $products->where('type', 3)->groupBy('x')->orderBy('x')->get();
但是当我生成这段代码时, 它让它进入链,并且 $type_2 永远不会返回。因为它在 type_1 内部搜索。
这个逻辑有什么问题?
【问题讨论】:
标签: laravel