if you are in your 'Hotel' model and trying to access the guests in the hotel, then (assuming your relationships are correct , the foreign keys are set up, and the method is named 'guest') in your Hotel model you could use:
$guests = Hotel::find($hotel_id)->guest; //or 'findOrFail($user_id)' ?
Should bring back all guests associated with the hotel id.
To add some more to this:
$guests = Hotel::find($hotel_id)->guest;
will return a Collection.
$guests = Hotel::find($hotel_id)->guest();
will return all models.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community