将查询从Mysql转换为Eloquent Laravel

时间:2015-02-10 09:32:19

标签: laravel-4 eloquent

我需要帮助将Mysql查询转换为Eloquent Laravel

 SELECT SUM((id_user=7) * `commission_agent`) AS sum7,SUM((id_user=8) * `commission_agent`) as sum8 FROM agents_commission

1 个答案:

答案 0 :(得分:1)

如果您正确设置了代理商佣金模型,则可以使用以下内容:

AgentCommission::select(DB::raw("SUM((id_user=7) * {commission_agent {1}} {commission_agent {1}}