所以我有这段代码:
$collectionOfProducts = \DB::table('products_specif')->whereIn('size',$arrayOfAttributes)->whereIn('color',$arrayOfAttributes)->whereIn('material',$arrayOfAttributes)->get('product_code');
$product_codes = $collectionOfProducts->unique();
dd($product_codes->toArray());
$arrayOfProducts = \DB::table('products')->whereIn('product_code',$product_codes)->get();
return view('pages.products', compact('arrayOfProducts','type'));
dd() 响应:
array:4 [▼
0 => {#1252 ▼
+"product_code": "SocksCode"
}
4 => {#1257 ▶}
9 => {#1262 ▶}
13 => {#1266 ▶}
]
我想在我的whereIn语句中使用 $product_codes,但我不能因为开头的那些数字 (0,4,9,13)。如何将此集合/数组转换为简单的“product_code”:“code”数组?
开心每一天1111