예제 #1
0
 /**
  * To comply with the Google Nest API rules, entries older than 10 days will be deleted.
  *
  * This also means I have to write some kind of "summary" thing for entries ~ 9 days old so they will be available in stats.
  *
  */
 public function complyWithGoogleTerms()
 {
     $date = Carbon::now()->startOfDay();
     // 22 feb 00:00:00
     $date->subDays(7);
     // 12 feb 00:00:00
     $count = LogEntry::where('time', '<', $date->format('Y-m-d H:i:s'))->count();
     LogEntry::where('time', '<', $date->format('Y-m-d H:i:s'))->delete();
     echo 'Deleted ' . $count . ' log entries.';
 }