Count the votes of an article

Posted 9 months ago by SmokeTM

Hey guys,

wanna count the votes of an article according to an authenticated user. So this means I wanna count all rows where = and where the article belongst to the authenticated user.

What I have so far

$articles = Article::WithCount('votes')->with('votes')->where('user_id', auth()->user()->id)->get();

Now $articles has two ids for which I wanna count the rows in my article_votes table, but how can I do that?

Best regards

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.