我想要金额列月份与当前年份的和

时间:2019-04-30 03:32:02

标签: laravel

我想要本年度的金额列月份的总和。在我的数据库中只有2019年4月的总和是658 /-。但它将显示在2019年12月。这是我的代码

if($dt_static == "This_Year"){   
                        $fm = str_replace('0','',Carbon::parse('first day of January')->format('m'));         
                        $lm = str_replace('0','',Carbon::parse('last day of december')->format('m')); 

                        $Target_Arch_Graph = [];                       
                        for($k=$fm; $k<=$lm; $k++)
                         {   
                            $Get_Target_Arch_Graph = DB::table('bid_project')
                                ->where('bid_project.status', '=', 'Winner')
                                ->whereMonth('date', date('m', strtotime('-'.$k.' month')))                               
                                ->sum('amount');
                               $Target_Arch_Graph[] = json_decode('['.$fm++.','.$Get_Target_Arch_Graph.']', true); 
                         }

                         dd($Target_Arch_Graph);
            }

0 个答案:

没有答案
相关问题