Exemplo n.º 1
0
 /**
  * Deletes all user activities.
  *
  * @return void
  */
 public function deleteAll()
 {
     UserActivity::truncate();
 }
Exemplo n.º 2
0
 /**
  * Deletes old user activities so that the database table can't
  * get fat.
  *
  * @param  int Delete activities older than x weeks (1 at least)
  * @return void
  */
 public function deleteOld($weeks = 1)
 {
     $weeks = (int) $weeks;
     if ($weeks < 1) {
         throw new Exception('UserActivities: $weeks is smaller than 1!');
     }
     UserActivity::where('created_at', '<', DB::raw('NOW() - INTERVAL ' . $weeks . ' WEEK'))->delete();
 }