企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
重要部分: ->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(); ~~~