jeudi 28 juillet 2016

Laravel Eloquent - how to relate table to another by two fields

Having two tables User and Mail

MailTable:

\mail
\--|id
\--|user_id
\--|from_user_id
\--|other_fields

UserTable:

\user
\--|id
\--|name
\--|other_fields

the Mail table is related to user by two fields => user_id and from_user_id, how to use eloquent to fetch data related to user to get inbox and outbox(sent) for one user?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire