更新时间:2023-01-30 12:29:09
您将不得不注入一些原始sql,但这并不是一场噩梦:
You will have to inject some raw sql, but it's not a nightmare:
$referenceIds = viewTable::orderBy('score', 'DESC')->lists('product_id');
$referenceIdsStr = implode(',', $referenceIds);
$products = Product::whereIn('id', $rederenceIds)->orderByRaw(DB::raw("FIELD(product_id, $referenceIdsStr)"))->get()->all();