/** * Cleanup tables as scheduled action */ public static function cleanupTablesSchedule() { // calculate date (now - 1week) for sql query $date = (new \DateTime('now'))->modify('-1 week')->format('Y-m-d'); UserNotification::where('created_at', '<=', $date)->delete(); UserLog::where('created_at', '<=', $date)->delete(); }