dimanche 8 février 2015

Like structure table with Laravel and showing the most popular content at top


I am using Laravel to creating a website, my users can post questions and other users can write their comments under the post, each comment have Up vote and Down vote, and users can voting for comments.


I need most liked (Up vote) shows topper than others..


This is my database structure and I join them together:


comment table:



comment_id | question_id | user_id | timestamp


up and down votes table (like):



like_id | comment_id | like_type | user_id | timestamp


note:like_type is an enum on mysql and its values are upvote and downvote.


1-What is the mysql query and Laravel codes for that?


2-Is my database Structure right?





Aucun commentaire:

Enregistrer un commentaire