get('start', ''); $end = $request->get('end', ''); if(empty($start)){ $start = date('Y-m-d', strtotime('-30 days')); } if(empty($end)){ $end = date('Y-m-d'); } $data = SaleLog::getSales($start, $end); $soldAt = $data->column('sold_at'); $totalSales = $data->column('total_sales'); return json(['code' => 0, 'data' => ['sold_at' => $soldAt, 'total_sales' => $totalSales]]); } public function apiGetSalesGoods(Request $request) { $start = $request->get('start', ''); $end = $request->get('end', ''); $order = $request->get('order', 'total_sales'); if(empty($start)){ $start = date('Y-m-d', strtotime('-30 days')); } if(empty($end)){ $end = date('Y-m-d'); } $data = SaleLog::getSalesGoods($start, $end, $order); $goodsName = $data->column('goods_name'); $totalSales = $data->column('total_sales'); $totalNum = $data->column('total_num'); $totalNumSmall = $data->column('total_num_small'); return json(['code' => 0, 'data' => [ 'goods_name' => $goodsName, 'total_sales' => $totalSales, 'total_num' => $totalNum, 'total_num_small' => $totalNumSmall ] ]); } }