group by laravel

55

group by laravel -

$user_info = DB::table('usermetas')
                 ->select('browser', DB::raw('count(*) as total'))
                 ->groupBy('browser')
                 ->get();

laravel db::query update -

 DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));  

laravel group by with where clause -

$groupedSalesCampaign = Order::with('Campaign')
            ->where('isapproved','=','Y')
            ->groupBy('campaign_id')
            ->orderBy(DB::raw('COUNT(id)','desc'))
            ->get(array(DB::raw('COUNT(id) as totalsales'),'campaign_id'));

laravel grouping where -

User::where('username','john doe')
    ->where(function($query)
    {
        $query->where('age','>',30)
        ->orWhere('email','=','[email protected]');
    })
    ->toSql();

Comments

Submit
0 Comments