lundi 30 octobre 2017

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);             
            });          
            }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iJHBdN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire