1 comments

@vinod 2020-09-16 07:09:23

You can do like to get conversations of user:

$conversations = App\Conversation::with('messages')->where('user_id', $id)->get();

Where $id is user id and with('messages') return collection of messages for conversation. To access this you can do simply like:

foreach($conversations as $conversation){
  $conversation->messages;
}

@Zeone line 2020-09-16 07:39:26

thank you Sir that worked great ill love to read about this from the documentation if you can provide a link for it, thank you again

@vinod 2020-09-16 08:33:28

Here it is Click

@vinod 2020-09-16 08:36:26

And here also Eager Loading

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] How to get all Movies that are playing on a MovieTheater?

1 Answered Questions

Laravel Relations with tables

  • 2019-03-20 21:58:03
  • codddeerz
  • 36 View
  • 0 Score
  • 1 Answer
  • Tags:   laravel eloquent

2 Answered Questions

[SOLVED] Laravel Get All Messages between 2 Users from DB

  • 2018-01-23 14:34:09
  • paulamiller
  • 523 View
  • 0 Score
  • 2 Answer
  • Tags:   laravel laravel-5

1 Answered Questions

1 Answered Questions

Group Conversation by latest message Laravel

1 Answered Questions

[SOLVED] Laravel group messages by date

1 Answered Questions

[SOLVED] Laravel get conversation where users in array

  • 2016-12-10 11:19:15
  • Bisgaard
  • 750 View
  • 0 Score
  • 1 Answer
  • Tags:   php laravel rest api

1 Answered Questions

[SOLVED] Store offers() which have user_id and article_id - laravel

2 Answered Questions

Sponsored Content