我有一个数据集。我的返回数据是这样的:
userId:2
movieId:2
rating:2
userId:2
movieId:3
rating:5
我想得到这样的数据:
userId:2
movieId:{2,3}
rating:{2,5}
我可以通过映射来完成吗?
$userX = Rating::where("userId", '=', $id)
->pluck('movieId')->toArray();
$data = Rating::where("userId", '!=', $id)
->whereIn('movieId', $userX)
->orderby('userId')
慕婉清6462132
慕尼黑5688855
随时随地看视频慕课网APP