mlazuardy

whoops highlighted the get(); any idea? i use the method in show

mlazuardy

is there another way method sir? please help me @jovanvta

jovanvta

Problem is in groupBy. Try this:

$popular_tags = DB::table('post_tag')
                      ->join('tags', 'post_tag.tag_id', '=', 'tags.id')
                     ->select(DB::raw('count(*) as repetition, tags.name, post_tag.tag_id'))
                     ->groupBy('post_tag.tag_id')
                     ->orderBy('repetition', 'desc')
                     ->get();

or:

$popular_tags = DB::table('post_tag')
                      ->join('tags', 'post_tag.tag_id', '=', 'tags.id')
                     ->select(DB::raw('count(post_tag.tag_id) as repetition, tags.name'))
                     ->groupBy('post_tag.tag_id')
                     ->orderBy('repetition', 'desc')
                     ->get();
mlazuardy

still same error sir @jovanvta

jovanvta

There is always another way or method :-) Lets try first solution without join again.

$popular_tags = DB::table('post_tag')
                     ->select(DB::raw('count(tag_id) as repetition, tag_id'))
                     ->groupBy('tag_id')
                     ->orderBy('repetition', 'desc')
                     ->get();
mlazuardy

okay the error is gone, now, i need to looping it with foreach or just call it?

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