Laravel Advanced Having

How do I use advanced having clause same as where clause in below code? Getting error Method having does not exist.

$follows=$request->get('follows');
        $db = DB::table('tabel_1 as tbl')
            ->leftJoin('table_2 as tb2', 'tbl.col1', '=', 'tb2.col1')
            ->leftJoin('table_3 as tb3', 'tbl.col1', '=', 'tb3.col1')
            ->select('tbl.col1','tbl.name','tb2.insta_followedByCount','tb3.twit_followers_count',DB::raw('SUM(tb2.insta_followedByCount+tb3.twit_followers_count) as ptotal'))
            ->groupBy('tbl.col1','tbl.name','tb2.insta_followedByCount','tb3.twit_followers_count')
            ->orderBy('ptotal', 'desc')
            //->having('ptotal', '>=', 5000000)
            ->get();

            if($follows){
            $db = $db->having(function ($query) use ($follows) {
            $query
            ->having('ptotal', '>=', $follows);             
            });          
            }

The reason you're getting the Method having does not exist error is because it's a method of a Query Builder, not a Collection.

Once you do:

$db = DB::table() ... ->get();

the $db value contains the result of the query. If you want to be able to reuse the query save it to a new variable:

$query = DB::table('tabel_1 as tbl')
        ->leftJoin('table_2 as tb2', 'tbl.col1', '=', 'tb2.col1')
        ->leftJoin('table_3 as tb3', 'tbl.col1', '=', 'tb3.col1')
        ->select('tbl.col1','tbl.name','tb2.insta_followedByCount','tb3.twit_followers_count',DB::raw('SUM(tb2.insta_followedByCount+tb3.twit_followers_count) as ptotal'))
        ->groupBy('tbl.col1','tbl.name','tb2.insta_followedByCount','tb3.twit_followers_count')
        ->orderBy('ptotal', 'desc');

$db = $query->get();
if($follows){
  $db = $query->having(...);
}