where('user_id',15)->pluck('store_id')->toArray(); $res = Store::query()->with(['ShoppingCart' => function($query) { $query->with('goods'); }])->whereIn('id',$storeIds) ->get(); foreach ($res as &$k){ $k->subtotal = '99.90'; } return $res; } public function check($goodsId) { return mt_rand(0,6); } public function undo() { $storeIds = Db::table('lanzu_shopping_cart')->where('user_id',198)->pluck('store_id')->toArray(); $res = Store::query()->with(['ShoppingCart' => function($query) { $query->with('goods'); }])->whereIn('id',$storeIds) ->get(); foreach ($res as &$k){ $k->subtotal = '99.90'; } return $res; } public function countGoods() { return mt_rand(1,100); } public function getTotal() { $randomFloat = rand(100,999)/100; return $randomFloat; } }