select('uid')->get(); $channels = []; foreach ($nissaya_channel as $key => $value) { # code... $channels[] = $value->uid; } $this->info('channel:'.count($channels)); $maxDay = 300; $file = "public/export/nissaya-daily.csv"; Storage::disk('local')->put($file, ""); #按天获取数据 for($i = 1; $i <= $maxDay; $i++){ $day = strtotime("today -{$i} day"); $date = date("Y-m-d",$day); $strlen = Sentence::whereIn('channel_uid',$channels) ->whereDate('created_at','=',$date) ->sum('strlen'); $this->info($date.','.$strlen); Storage::disk('local')->append($file, $date.','.$strlen); } return 0; } }