79836004

Date: 2025-12-02 14:56:59
Score: 0.5
Natty:
Report link

I know this is an old thread, but in case anyone comes across this, as of 11.22 Eloquent now supports this use case elegantly with the chaperone() method, which hydrates the parent model without doing an extra query.

So I think the implementation for the above example would be:

$place = Place::with([
    'hotels' => fn ($hotels) => $hotels->chaperone(),
])->get();
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: sarahg