xiamihow

846 经验值

老师,请问一下,下面这个有没有什么更优雅的写法呢?

$opening = OpeningView::whereBetween('complated_at', $ptime)
            ->where('isComplated', 1)
            ->where('price', '>', 0)
            ->select(
                DB::raw('sum(price) as price'), //包含退款的实际业绩  + 退款
                DB::raw('count(id) as open_count'),//包含退款总单数  + 退款
                DB::raw('sum(case when  price>0  then price end) as openPrice'),//不包含退款的业绩
                DB::raw('count(case when  price>0  then 1 end) as openCount'))//不包含退款的总单数
            ->first();

老师,想问一下,如果favorites表还有其他字段呢,比如created_at和udated_at,这两个字段要怎么添加数据?

博主,laravel5.4,上传图片无法上传是怎么回事呢?