聯接的列我有以下代碼:如何返回列,按照一定的順序(雄辯)
Incident::where('id','<','35')->with('priority')->paginate(15);
眼下這個返回如下: ID,標題,描述,priority_id和優先對象。
我想只檢索ID,標題和優先級對象,沒有描述,也沒有priority_id但我希望它們按照特定的順序,如下所示: ID,優先級和標題。
但是,當我做到以下幾點:
Incident::where('id','<','5')->with('priority')->paginate(15, array('id', 'priority', 'title'));
我得到一個錯誤說沒有發現列incidents.priority。
有沒有什麼辦法只選擇我想要的列和我想要的順序,當他們中的一個通過FK被引用?
謝謝!
這可能是幫助you.check此鏈接https://packagist.org/packages/witty/laravel-table-view – Shuvo
選中此:http://stackoverflow.com/questions/23612221/how-to-exclude -sertains-columns-while-using-eloquent –
我無法想象一個場景,依賴於數組的順序 – tam5