Answer the question
In order to leave comments, you need to log in
How correct is the following Eloquent/Laravel code?
There is a certain list which we receive from basis.
Let's call it a list of people.
protected function getPeoples($id) {
$results = Peoples::all();
return $results;
}
protected function getCases($id) {
$results = Cases::where('PeopleID', '=', $id)->get();
return $results;
}
protected function getCases($id) {
$results = Cases::where('PeopleID', '=', $id)->get();
foreach ($results as $result) {
$result->bills = Bills::where('CaseID', '=', $result->CaseID)->with('statuses')->get(array('BatchID'));
}
return $results;
}
Answer the question
In order to leave comments, you need to log in
Try to use has-many-through links to avoid extra request for bills.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question