lundi 21 septembre 2015

Optimal table structure for message system in Laravel 5

I'm trying to figure out how to make the most efficient messaging system for users.

My idea is that (very similar to Facebook) when a user sends a message to another user, then it creates a thread where all messages send between the users are displayed. It is important that new messages are flagged as unread for the recipient.

I want to leverage Laravels relations.

If I create a pivot table that contains the recipient id and sender id, how can I get Laravel to differentiate the 2 users using Laravels relations, so that I can easily get a list of threads where the user is involved, whether he's just the recipient, sender or both.

A thread does not need a title/subject.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire