Thank you for your quick reply, but that's not working. The fields from the sub-tables (like TableDEF) are not selectable with this method. Also not with a prefix like "TableDEF.fieldname"
Select fields in complex with() queries
Hello @all,
i am currently struggeling in one of my data-selections. the data are being read from a mysql table over eloquent models.
Example:
TableXYZ::where("parentID","=",10) ->take(100) ->skip(5) ->with("TableABC") ->with("TableABC.TableDEF")
The query itself works fine and returns me all (ALL !) fields of all tables. That's too much and i do not want to send most informations out in json responses. So i have to filter / select the fields i need.
Have somebody already a solution for this problem ?
Thanks a lot, Jugi
Yes I was wondering because the with method with callback to select some fields should work for the original question.
Maybe the select have to include the foreign keys ? Because the eager loading mechanism needs foreign keys to map the related objects to the parent object.
Please or to participate in this conversation.