怎么才能實(shí)現(xiàn)這個(gè)查詢呢?Sale::with(['catalog']) ->whereIn('id', $ids) ->update(['price' => DB::raw('catalog.price')]);這不起作用,它顯示未定義的表...我嘗試輸入表的名稱,但它是相同的。在互聯(lián)網(wǎng)上我總是找到簡(jiǎn)單的查詢:Sale::with(['catalog']) ->whereIn('id', $ids) ->update(['price' => 5]);好的!當(dāng)我想要更新具有相同值的所有行時(shí)很容易,此外當(dāng)您想要使用同一個(gè)表的列進(jìn)行更新時(shí)也很容易,例如:Sale::with(['catalog']) ->whereIn('id', $ids) ->update(['price' => DB::raw('price_alternative')]);但是如何使用另一個(gè)具有關(guān)系的表的列呢?我還沒有找到解決方案。我知道這可以使用整個(gè)原始查詢來解決,但我想知道是否可以通過雄辯的方式來實(shí)現(xiàn)
Laravel eloquent 使用關(guān)系列更新列
慕桂英4014372
2023-09-08 21:55:21