// 比如说用户 user_id=1 购买了 商家seller_id 1,2,3的商品
$order = [
[
"id" => 1,
"user_id" => 1, // 用户
"seller_id" => 1, // 商家 1
"goods_id" => 1,
],
[
"id" => 2,
"user_id" => 1,
"seller_id" => 2, // 商家 2
"goods_id" => 2,
],
[
"id" => 3,
"user_id" => 1,
"seller_id" => 3, // 商家 3
"goods_id" => 3,
]
];
// 怎么用 Collection 优化成这个样子?
$data = [
'id' => '1',
'user_id' => '1',
'shop' => [
[
[
'seller_id' => 1,
'test' => 'Test commodity'
],
[
'seller_id' => 2,
'test' => 'Test commodity'
],
[
'seller_id' => 3,
'test' => 'Test commodity'
]
]
]
];
修改的评论也不能少于六个字哦!
0
分享