Please someone should help me convert this SQL Query to Laravel 5.4 Query Builder syntax. I have searched for solutions and found some but not exactly as I wanted.
I have 3 tables:
Feeds: - feed_id - user_id - feed_title
Users: - id - username
Commments: - comment_id - feed_id - text - user_id
On my view returned, I want to see the feed title, user's user name, and a count of all comments to each feed. Like what you see on facebook: displaying the amount of comments on each post displayed. Please I really need this to be done:
This is the SQL code I tried in MySQL Database, it kinda works there but returns an error when I try to implement the same in Laravel
select *, count(comments.comment_id) as comment_count
from `feeds`
inner join `users` on
`feeds`.`user_id` = `users`.`id`
inner join `comments` on
`feeds`.`feed_id` = `comments`.`comment_feed_id`
group by `comments`.`comment_feed_id`