postData = $postData; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->line(date('Y-m-d H:i:s')."开始统计昨日最佳内容"); $postData = $this->postData ->where('created_at', '>=', Carbon::yesterday()->startOfDay()->toDateTimeString()) ->where('created_at', '<=', Carbon::yesterday()->endOfDay()->toDateTimeString()) ->get(); $postId = 0; if($postData){ $postScore = 0; foreach ($postData as $post) { $score = $post->pv + $post->collect_count + $post->share_count + $post->comment_count; if($score>$postScore){ $postId = $post->post_id; } } } Redis::set('yesterday_great_post', $postId); $this->line(date('Y-m-d H:i:s')."统计昨日最佳内容结束".$postId); } }