Ejemplo n.º 1
0
 /**
  * レコード作成処理
  */
 private function existRecord()
 {
     $analysis = $this->analysis->where('date', $this->date)->first();
     if (empty($analysis)) {
         $analysis = $this->analysis->newInstance();
         $analysis->date = $this->date;
         $analysis->save();
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $text = 'report date: ';
     $analysis = $this->analysis->where('date', date('Ymd', strtotime('-1 day')))->first();
     if ($analysis) {
         $text .= date('Y/m/d', strtotime($analysis->created_at));
         $text .= PHP_EOL;
         $text .= "page_view: {$analysis->page_view}";
         $text .= PHP_EOL;
         $text .= "new_post: {$analysis->new_post}";
     } else {
         $text .= $text = date('Y/m/d', strtotime('-1 day'));
         $text .= PHP_EOL;
         $text .= "page_view: 0";
         $text .= PHP_EOL;
         $text .= "new_post: 0";
     }
     $this->slackBot->post($text);
 }