嘗試將with()函數(shù)與聯(lián)接一起使用時遇到問題:$query = Model::query()->with([ 'relationOne', 'relationTwo', ...]);$query->join(DB::raw("( select * from <models_table> where <some_condition>) as new_model"), 'new_model.id', '=', '<models_table>.id');$query->paginate($rpp);通話后paginate($rpp),我收到了所有附加了適當關(guān)系的項目,但沒有加入表格(又名new_model)。有沒有辦法new_model與關(guān)系一起檢索?
使用 Laravel Eloquent 的 with() 函數(shù)和內(nèi)部連接
阿波羅的戰(zhàn)車
2022-07-16 17:11:44