Answer the question
In order to leave comments, you need to log in
How to make and get data through laravel connection?
I have 2 tables,
1 - users
2 - messages
The messages table has fields - id, sender_id, receiver_id - sender and receiver.
How to make a connection that would receive both sent and received messages in one array.
Separately, it will.
public function incomeMessages()
{
return $this->hasMany(UserMessage::class, 'receiver_id');
}
public function sentMessages()
{
return $this->hasMany(UserMessage::class, 'sender_id');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question