belongsTo(User::class); } public static function deleteLogsFromDB() { $cutoff = Carbon::now('UTC')->subMonths(3)->toDateTimeString(); $count = count(self::where('created_at', '<', $cutoff) ->orderBy('created_at', 'desc') ->get()); if ($count > 0) { self::where('created_at', '<', $cutoff)->delete(); return "$count old log(s) deleted from the database."; } return 'No logs older than 3 months found.'; } }