I am writing a conversation system for my application using the Now, when I create a new How can I do this? I currently have the bottom. I have 3 database tables Conversation: Conversation_user: Message: I have 2 models Conversation Message it worked Laravel framework. If I'm doing hard work in the database, then I can have a conversation at present.
conversation in a new
conversation , then call me
Conversations table and user and
conversation_id to
conversation_user .
id |
id | Conversation_id | User_id
ID | Message | User_id | Conversation_id | Conversation made
class conversation eloquent {public $ table = 'conversations'; Public $ includes = array ('user', 'message'); Public function user () {return $ this-> Affiliation Value ('User'); } Public Function Message () {Return $ this- & gt; Hayman ('message'); }}
Class message spreads in headlines {public $ table = 'messages'; Public $ includes = array ('user', 'conversation'); Secure $ fillable = array ('message', 'user_id', 'conversation_id'); Public function user () {return $ this-> Affiliation ('user'); } Public function Conversation () {Return $ this- & gt; Association ('Conversation'); }}
$ conversation = Conversation :: Creating (array ()); $ Conversation- & gt; User () - & gt; (Sentry :: getUser () -> ID); $ Conversation- & gt; User () - & gt; Gave ($ id); $ Conversation- & gt; Save ();
No comments:
Post a Comment