lundi 25 décembre 2017

How to retrieve data from multiple related tables based on a count in laravel

I have the following tables in my database:

  1. Blogs
  2. Blog_Comments
  3. Emotions
  4. Blog_emotion
  5. Users

Where Blog and Blog_comments has one to many relation. Emotions and Blog has many to many relation and blog_emotion is the pivot table. Lastly users and blogs has one to many relation.

I want to get the blogs with max comment and max emotion with the user. How can I do so in eloquent. I am using laravel 5.4



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire