What about if you use leftjoin ?
Jan 3, 2018
4
Level 2
How to write a query within another query ?
Dear friends,
My problem is i have 3 tables with some relation. But I need a logic which write in the logic code below
$tr_req_data = TransferRequest::with(['stations' => function ($qry) {
$qry->with(['localbody' => function ($qrylocalbody) {
$qrylocalbody->where("stations.requested_station","=","localbody.lbid");
}]);
}])->paginate(5);
But I got some exception like
"message": "SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table \"ulbgt_stations\"\nLINE 1: ...e \"ulbgt_local_bodies\".\"lbid\" in (, , ) and \"ulbgt_sta...\n ^ (SQL: select * from \"ulbgt_local_bodies\" where \"ulbgt_local_bodies\".\"lbid\" in (1, 2, 3) and \"ulbgt_stations\".\"requested_station\" = localbody.lbid)",
Please advise how this concept can do?
Thanks
Please or to participate in this conversation.