Laravel Eloquent Joining Query (Multiple clauses of purpose in joining)

return TableA::leftJoin('table_b as b',function($join){
                $join->on('b.foreign_id','=','table_a.id');
                $join->where('b.status','=',1);
            })
            ->where('table_a.group_name','emmet')
            ->groupBy('b.color')
            ->get([
                'table_a.*'
                DB::raw('SUM(b.price) as total_price')
            ]);

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine