Laravel: General Tips - maple-dev-team/docs GitHub Wiki
- IF YOU ARE NOT INSIDE A RESOURCE, BECAUSE WILL A QUERY FOR EACH ROW
$purchase = Purchase::where('id', $id)->with('details')->first();
$purchase->details
Do this:
$purchase = Purchase::where('id', $id)->first();
$purchase->details
Laravel will query the details when/if you need to use the details
Simplify with eloquent:
before:
$result = Transfer::where('id', $id)->get();
$result[0]
after:
$result = Transfer::find($id);
$result