How to calculate the total likes of all posts of a user

Posted 5 months ago by Dev0ps

i need to count users all posts like


$post = Post::whereUserId(auth::id())->get('id');

$postlikes = PostLike::wherePostId($post)->count('post_id);

it's work in foreach. but I am looking for some more convenient way

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.