如何使用不同的值(从 1 到 3)更新前三个结果:
查询以获取前 3 个结果:
$top3 = DB::table('quests')
->orderby('score', 'desc')
->take(3)
->pluck('id');
查询更新排名为 1 到 3 的列:
DB::table('quests')->whereIn('id', $top3)
->first()->update(['rank', 1])
->second()->update(['rank', 2])
->third()->update(['rank', 3]);
//of course the above updates are from my imagination :)
//just trying to describe what I'm trying to do
呼啦一阵风