Saturday, March 4, 2017

Laravel + MongoDB - Retrieving all embedded models?

Let's say there is a User model that embedsMany House models.

public function houses()
    {
        return $this->embedsMany('App\House');
    }

Is there a way to directly retrieve a list of all houses for all users, without first retrieving all users and then iterating through each users embedded houses?

Passing $houses = House::all(); to the view, returns nothing.



via JanisOzolins

Advertisement