-2

I have 3 tables Table A, Table B and Table C

Table 1 has many Table B and Table B has many Table C

I am using this query

TableA::where(whereclause)->with(TableB.TableC)

Now i want to select some column from table c in controller is there any way to get column from table c like this

TableA::where(whereclause)->with(TableB:col1,col2)
Jack
  • 1
  • 2
    Welcome, to improve your experience on SO please [take the tour](http://stackoverflow.com/tour) and read [how to ask](https://stackoverflow.com/help/how-to-ask), an [On Topic question](https://stackoverflow.com/help/on-topic), then look at the [Question Check list](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist), the [perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) and how to create a [Minimal, Complete and Verifiable Example](http://stackoverflow.com/help/mcve) – RiggsFolly Apr 22 '21 at 08:25

1 Answers1

0
TableA::where(whereclause)->with(['TableB' => function($query) {
    $query->select('id','username');
}])->get();
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38
  • Thanks for the response, but it seems that you miss a point I need it selected columns from TableC, and do we have another way to get it like i mentioned in my second query above like this TableA::where(whereclause)->with(TableB:col1,col2) – Jack Apr 22 '21 at 11:01