ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
重要部分: ->orderBy(DB::raw('FIND_IN_SET(id, "' . implode(",", $ids) . '"' . ")")) ~~~ $ids = array_column($data,'word_id'); return WordStock::whereIn('id', $ids) ->where('status', 1) ->orderBy(DB::raw('FIND_IN_SET(id, "' . implode(",", $ids) . '"' . ")")) ->get(['id as word_id','type','cn_title','uy_title','en_title']) ->each(function ($item, $index) use ($data){ $item->sort= array_column($data,'sort')[$index]; })->toArray(); ~~~