Laravel 4 Relationship: messaging system
I followed the suggestions from user ehp in order to build a lightweight messaging-system: https://stackoverflow.com/a/18717864/1084315 Users: id | username Messages: id | from | content user_messages: user_id | message_id class User extends Eloquent { public function messages() { return $this->belongsToMany('Message'); } public function sent_messages() { return $this->hasMany('Messages', 'from'); } } class Message extends Eloquent { public function from() { return $this->belongsTo('User', 'from'); } public function to() { return $this->belongsToMany('User'); } } I create a message like this: