ChrisBratherton
ChrisBratherton

Reputation: 1590

Querying a Pivot table in Laravel 4

I have a Email model with the table 'messages' that contains all the message data.

I also have a pivot table 'message_users'.

How could I return all the messages that a user is associated with?

Upvotes: 0

Views: 36

Answers (1)

ChrisBratherton
ChrisBratherton

Reputation: 1590

It was a simple question of adding the relationship to the Users model as well so now I can call: $user->emails; to retrieve the emails associated with that user.

Upvotes: 1

Related Questions